forked from hplush/slowreader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.test.ts
53 lines (43 loc) · 966 Bytes
/
settings.test.ts
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
import { keepMount } from 'nanostores'
import { equal } from 'node:assert'
import { afterEach, beforeEach, test } from 'node:test'
import {
generateCredentials,
preloadImages,
signOut,
theme,
userId
} from '../index.ts'
import { cleanClientTest, enableClientTest } from '../test/utils.ts'
let restarts = 0
beforeEach(() => {
enableClientTest({
restartApp() {
restarts += 1
}
})
})
afterEach(async () => {
await cleanClientTest()
restarts = 0
})
test('generates user data', () => {
userId.set(undefined)
keepMount(userId)
generateCredentials()
equal(typeof userId.get(), 'string')
})
test('signs out', async () => {
userId.set('10')
keepMount(userId)
equal(restarts, 0)
await signOut()
equal(userId.get(), undefined)
equal(restarts, 1)
})
test('has store for theme', () => {
equal(theme.get(), 'system')
})
test('has store for images preload settings', () => {
equal(preloadImages.get(), 'always')
})