FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode-cli/test/test_cache.js at master · DanielChuDC/leetcode-cli · GitHub
DanielChuDC
/
leetcode-cli
Public
forked from
skygragon/leetcode-cli
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
leetcode-cli
/
test
/
test_cache.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
48 lines (38 loc) · 1.11 KB
Breadcrumbs
leetcode-cli
/
test
/
test_cache.js
Copy path
File metadata and controls
48 lines (38 loc) · 1.11 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
'use strict'
;
const
assert
=
require
(
'chai'
)
.
assert
;
const
rewire
=
require
(
'rewire'
)
;
const
th
=
require
(
'./helper'
)
;
describe
(
'cache'
,
function
(
)
{
let
cache
;
const
K
=
'.test'
;
const
V
=
{
test
:
'data'
}
;
beforeEach
(
function
(
)
{
th
.
clean
(
)
;
const
file
=
rewire
(
'../lib/file'
)
;
file
.
cacheDir
=
(
)
=>
th
.
DIR
;
cache
=
rewire
(
'../lib/cache'
)
;
cache
.
__set__
(
'file'
,
file
)
;
cache
.
init
(
)
;
}
)
;
it
(
'should get ok when not cached'
,
function
(
)
{
cache
.
del
(
K
)
;
assert
.
equal
(
cache
.
get
(
K
)
,
null
)
;
assert
.
equal
(
cache
.
del
(
K
)
,
false
)
;
}
)
;
it
(
'should get ok when cached'
,
function
(
)
{
assert
.
equal
(
cache
.
set
(
K
,
V
)
,
true
)
;
assert
.
deepEqual
(
cache
.
get
(
K
)
,
V
)
;
assert
.
equal
(
cache
.
del
(
K
)
,
true
)
;
}
)
;
it
(
'should list ok when no cached'
,
function
(
)
{
const
items
=
cache
.
list
(
)
;
assert
.
equal
(
items
.
length
,
0
)
;
}
)
;
it
(
'should list ok when cached'
,
function
(
)
{
assert
.
equal
(
cache
.
set
(
K
,
V
)
,
true
)
;
const
items
=
cache
.
list
(
)
;
assert
.
equal
(
items
.
length
,
1
)
;
assert
.
equal
(
items
[
0
]
.
name
,
K
)
;
assert
.
equal
(
items
[
0
]
.
size
,
JSON
.
stringify
(
V
)
.
length
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL