@johnf/react-native-owl
Version:
Visual regression testing for React Native
21 lines (20 loc) • 685 B
JavaScript
;
import { promises as fs } from 'fs';
import { fileExists } from "./file-exists.js";
describe('file-exists.ts', () => {
const accessMock = jest.spyOn(fs, 'access');
beforeEach(() => {
accessMock.mockReset();
});
it('should check if a file exists - true', async () => {
accessMock.mockResolvedValueOnce();
const result = await fileExists('./hello.txt');
expect(result).toBe(true);
});
it('should check if a file exists - false', async () => {
accessMock.mockRejectedValueOnce(undefined);
const result = await fileExists('./file-does-not-exist.txt');
expect(result).toBe(false);
});
});
//# sourceMappingURL=file-exists.test.js.map