This repository has been archived by the owner on Mar 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cache): handle empty resource lists
- Loading branch information
Showing
2 changed files
with
39 additions
and
8 deletions.
There are no files selected for viewing
43 changes: 37 additions & 6 deletions
43
src/lib/todoist/local-rest-adapter/conf-cache/tests/conf-cache.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,47 @@ | ||
/* eslint-disable jest/no-hooks */ | ||
jest.mock('@/lib/todoist/local-rest-adapter/conf-cache'); | ||
|
||
import { CacheStore } from '@/lib/todoist/local-rest-adapter/conf-cache'; | ||
import { LOCAL_FIXTURES } from '@/tests/helpers/fixtures'; | ||
import fs from 'fs'; | ||
import { spyOnImplementing } from 'jest-mock-process'; | ||
|
||
// TODO: mock fs.writeWileSync() | ||
// jest.mock('write-file-atomic', (path: string, data: any) => {}); | ||
// let fsMock = spyOnImplementing(fs, 'writeFileSync', (...args: any) => args); | ||
|
||
let store; | ||
let store = new CacheStore({ | ||
cwd: 'src/tests/stores', | ||
configName: 'cache', | ||
cacheTimeout: 100, | ||
}); | ||
|
||
describe('unit: Cache timestamp store', () => { | ||
beforeEach(() => { | ||
store = new CacheStore({}); | ||
store.reset(); | ||
store.set('TASK', LOCAL_FIXTURES.tasks); | ||
}); | ||
|
||
it('.get()', () => { | ||
expect.assertions(2); | ||
|
||
expect(store.get('<missing>')).toBeUndefined(); | ||
expect(store.get('TASK')).toEqual(LOCAL_FIXTURES.tasks); | ||
}); | ||
|
||
it.todo('should test something'); | ||
it('.set()', () => { | ||
expect.assertions(2); | ||
store.set('ITEM', 'Item'); | ||
let cache = store.get('_cache'); | ||
|
||
expect(store.get('ITEM')).toBe('Item'); | ||
expect(cache).toBe(3); | ||
}); | ||
|
||
it.todo('.has()'); | ||
|
||
it.todo('.reset()'); | ||
|
||
it.todo('.isExipred()'); | ||
|
||
// afterAll(() => { | ||
// fsMock.mockRestore(); | ||
// }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters