-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandle-cache.test.ts
More file actions
36 lines (32 loc) · 984 Bytes
/
handle-cache.test.ts
File metadata and controls
36 lines (32 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// tslint:disable:no-let
import { expect } from 'chai'
import { range } from 'lodash'
import * as handleCache from '../../background/handle-cache'
describe('handle-cache', () => {
let localStorage = {}
before(() => {
global.chrome = {
storage: {
local: {
get: cb => cb(localStorage),
set: updates => (localStorage = { ...localStorage, ...updates }),
},
},
} as any
})
after(() => {
delete (global as any)['chrome']
})
it('only retains the latest 50 cached handles', async () => {
for (const i of range(51)) {
await handleCache.set({
domain: `domain-${i}`,
twitter_handle: `@${i}`,
non_default_twitter_handles: [],
})
}
expect(await handleCache.get('domain-0')).to.equal(null)
expect(await handleCache.get('domain-1')).to.have.property('twitter_handle', '@1')
expect(await handleCache.get('domain-50')).to.have.property('twitter_handle', '@50')
})
})