This repository was archived by the owner on Apr 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.js
More file actions
58 lines (45 loc) · 1.54 KB
/
Copy pathindex.test.js
File metadata and controls
58 lines (45 loc) · 1.54 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const {set, get, del, clear} = require('./index')
test(`Testing 'set' to add new entry to the cache`, () => {
set('day', 'friday')
expect(get('day')).toBe('friday')
})
test(`Testing 'set' to add new entry to the cache using numbers`, () => {
set('1234', 'value')
expect(get('1234')).toBe('value')
})
test(`Testing 'set' to add new entry to the cache using accents (removed)`, () => {
set('acción', 'value')
expect(get('acción')).toBe('value')
})
test(`Testing 'set' to add new entry to the cache using an object`, () => {
set({test: 'test'}, 'valueObj')
expect(get({test: 'test'})).toBe('valueObj')
})
test(`Testing 'set' to add new entry to the cache using an array`, () => {
set([1,2,3,4], 'valueArray')
expect(get([1,2,3,4])).toBe('valueArray')
})
test(`Testing persitance with 'get' from previous test`, () => {
expect(get('day')).toBe('friday')
})
test(`Testing 'set' to add new entry to the cache`, () => {
set('ephimeral', 'shouldberemovedsoon', 100)
expect(get('ephimeral')).toBe('shouldberemovedsoon')
})
test(`Testing ephimeral with 'get' from previous test to be gone`, () => {
setTimeout(() => {
const ephimeralVal = get('ephimeral')
expect(ephimeralVal).toBe(undefined)
}, 500)
})
test(`Testing non-existant entry with 'get' to be undefined `, () => {
expect(get('shoudlnotexists')).toBe(undefined)
})
test(`Testing deleting the existing 'day' entry`, () => {
del('day')
expect(get('day')).toBe(undefined)
})
test(`Testing clearing the whole cache`, () => {
clear()
expect(get('1234')).toBe(undefined)
})