forked from sheepzh/time-tracker-4-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhitelist-database.test.ts
More file actions
22 lines (19 loc) · 832 Bytes
/
whitelist-database.test.ts
File metadata and controls
22 lines (19 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import WhitelistDatabase from "@db/whitelist-database"
import storage from "../__mock__/storage"
const db = new WhitelistDatabase(storage.local)
describe('timer-database', () => {
beforeEach(async () => storage.local.clear())
test('1', async () => {
await db.add('www.baidu.com')
await db.add('google.com')
const list = await db.selectAll()
expect(list.sort()).toEqual(['www.baidu.com', 'google.com'].sort())
expect((await db.exist('www.baidu.com'))).toBeTruthy()
await db.remove('www.baidu.com')
await db.remove('www.baidu.com111')
expect((await db.selectAll())).toEqual(['google.com'])
expect((await db.exist('www.baidu.com'))).toBeFalsy()
await db.add('google.com')
expect((await db.selectAll())).toEqual(['google.com'])
})
})