aboutsummaryrefslogtreecommitdiff
path: root/webAO/__tests__/isLowMemory.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'webAO/__tests__/isLowMemory.test.ts')
-rw-r--r--webAO/__tests__/isLowMemory.test.ts22
1 files changed, 21 insertions, 1 deletions
diff --git a/webAO/__tests__/isLowMemory.test.ts b/webAO/__tests__/isLowMemory.test.ts
index 6428e17..870b40e 100644
--- a/webAO/__tests__/isLowMemory.test.ts
+++ b/webAO/__tests__/isLowMemory.test.ts
@@ -1,11 +1,31 @@
import { isLowMemory } from '../client/isLowMemory';
import { setOldLoading } from '../client';
+import { AO_HOST, setAOhost } from '../client/aoHost';
-// Mock the setOldLoading function
+// Mock the setOldLoading function and prevent any network requests
jest.mock('../client', () => ({
setOldLoading: jest.fn(),
}));
+// Mock any potential network requests
+jest.mock('../services/request', () => ({
+ __esModule: true,
+ default: jest.fn().mockResolvedValue(''),
+ request: jest.fn().mockResolvedValue(''),
+ requestBuffer: jest.fn().mockResolvedValue(new ArrayBuffer(0)),
+}));
+
+// Mock the fileExists function to prevent network requests
+jest.mock('../utils/fileExists', () => ({
+ __esModule: true,
+ default: jest.fn().mockResolvedValue(false),
+}));
+
+// Set AO_HOST to a valid URL before tests run
+beforeAll(() => {
+ setAOhost('https://example.com/');
+});
+
describe('isLowMemory', () => {
beforeEach(() => {
// Reset mock before each test to ensure isolation