Skip to content

Commit 8d264ee

Browse files
refactor: simplify test setup and improve readability in file-system tests
1 parent dbbdfee commit 8d264ee

1 file changed

Lines changed: 3 additions & 23 deletions

File tree

example/__tests__/file-system.harness.ts

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,18 @@
1-
import { describe, test, expect, beforeEach } from 'react-native-harness';
1+
import { describe, test, expect } from 'react-native-harness';
22
import { NativeFileSystem } from 'mendix-native';
33

44
describe('NativeFileSystem', () => {
5-
const testDir = 'harness-test-dir';
65
const testFile = 'test-file.txt';
7-
const testFilePath = `${testDir}/${testFile}`;
8-
9-
beforeEach(async () => {
10-
// Clean up any existing test files/directories
11-
try {
12-
const exists = await NativeFileSystem.fileExists(testFilePath);
13-
if (exists) {
14-
await NativeFileSystem.remove(testFilePath);
15-
}
16-
} catch (error) {
17-
// Ignore cleanup errors
18-
}
19-
});
206

217
describe('Constants', () => {
228
test('should have DocumentDirectoryPath defined', () => {
239
const documentDirectory = NativeFileSystem.DocumentDirectoryPath;
2410
const relativePath =
2511
NativeFileSystem.relativeToDocumentsAbsolutePath(testFile);
26-
expect(typeof NativeFileSystem.DocumentDirectoryPath).toBe('string');
27-
expect(NativeFileSystem.DocumentDirectoryPath.length).toBeGreaterThan(0);
12+
expect(typeof documentDirectory).toBe('string');
13+
expect(documentDirectory.length).toBeGreaterThan(0);
2814
expect(relativePath).toBe(`${documentDirectory}/${testFile}`);
29-
});
30-
31-
test('should have SUPPORTS_DIRECTORY_MOVE as true', () => {
3215
expect(NativeFileSystem.SUPPORTS_DIRECTORY_MOVE).toBe(true);
33-
});
34-
35-
test('should have SUPPORTS_ENCRYPTION as true', () => {
3616
expect(NativeFileSystem.SUPPORTS_ENCRYPTION).toBe(true);
3717
});
3818
});

0 commit comments

Comments
 (0)