fs.readFile = jest.fn((path, callback) => { return callback(null, JSON.stringify(mockData)); }); await serverUtils.readLocaleManifestFile(mockLocalesDir); expect(fs.readFile.mock.calls).toHaveLength(1); }); }); fs.readFile = jest.fn((path, callback) => { return callback(null, JSON.stringify(mockData)); }); await serverUtils.readLocaleFile({ module: 'module', localeFile: 'filename.json' }, mockLocalesDir); expect(fs.readFile.mock.calls).toHaveLength(1); }); }); fs.readFile = jest.fn((path, callback) => { return callback(null, JSON.stringify(mockData)); }); await serverUtils.loadLocaleFilesIntoStore(mockStore, modules, mockLocalesDir); expect(dispatchStub.mock.calls).toHaveLength(2); expect(fs.readFile.mock.calls).toHaveLength(2); }); it('should read the manifest file and locale file and call dispatch', async function () { fs.readFile = jest.fn((path, callback) => { return callback(null, JSON.stringify(mockData)); }); await serverUtils.loadLocaleFilesIntoStore(mockStore, modules, mockLocalesDir); expect(dispatchStub.mock.calls).toHaveLength(3); }); });
RecorderManager.dumpToDisk(); expect(mkdirp.sync.mock.calls.length).toBe(3); expect(fs.writeFileSync.mock.calls).toEqual([ ['utr_activity/dir1/file1.json', '1'], ['utr_activity/dir1/dir2/file2.json', '2'], }; RecorderManager.loadFromDisk(); expect(fs.readFileSync.mock.calls).toEqual(filePaths); expect(RecorderManager.recorderState).toEqual(expected); });
fs.readFile = jest.fn((path, callback) => { return callback(null, JSON.stringify(mockData)); }); await serverUtils.readLocaleManifestFile(mockLocalesDir); expect(fs.readFile.mock.calls).toHaveLength(1); }); }); fs.readFile = jest.fn((path, callback) => { return callback(null, JSON.stringify(mockData)); }); await serverUtils.readLocaleFile({ module: 'module', localeFile: 'filename.json' }, mockLocalesDir); expect(fs.readFile.mock.calls).toHaveLength(1); }); }); fs.readFile = jest.fn((path, callback) => { return callback(null, JSON.stringify(mockData)); }); await serverUtils.loadLocaleFilesIntoStore(mockStore, modules, mockLocalesDir); expect(dispatchStub.mock.calls).toHaveLength(2); expect(fs.readFile.mock.calls).toHaveLength(2); }); it('should read the manifest file and locale file and call dispatch', async function () { fs.readFile = jest.fn((path, callback) => { return callback(null, JSON.stringify(mockData)); }); await serverUtils.loadLocaleFilesIntoStore(mockStore, modules, mockLocalesDir); expect(dispatchStub.mock.calls).toHaveLength(3); }); });