-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.test.js
More file actions
85 lines (74 loc) · 2.01 KB
/
config.test.js
File metadata and controls
85 lines (74 loc) · 2.01 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import assert from 'node:assert/strict'
import { describe, it } from 'node:test'
import Config from './config.js'
describe('config', () => {
describe('get', () => {
it(`loads mysql test config`, async () => {
const cfg = await Config.get('mysql', 'test')
assert.deepEqual(cfg, mysqlTestCfg)
})
it(`loads mysql test config syncronously`, () => {
const cfg = Config.getSync('mysql', 'test')
assert.deepEqual(cfg, mysqlTestCfg)
})
it(`loads mysql cov config`, async () => {
const cfg = await Config.get('mysql', 'cov')
assert.deepEqual(cfg, mysqlTestCfg)
})
it(`loads mysql cov config (from cache)`, async () => {
process.env.NODE_DEBUG = 1
const cfg = await Config.get('mysql', 'cov')
assert.deepEqual(cfg, mysqlTestCfg)
process.env.NODE_DEBUG = ''
})
it(`loads http test config`, async () => {
const cfg = await Config.get('http', 'test')
assert.deepEqual(cfg, httpCfg)
})
it(`loads http test config syncronously`, () => {
const cfg = Config.getSync('http', 'test')
assert.deepEqual(cfg, httpCfg)
})
it(`detects NODE_DEBUG env`, async () => {
process.env.NODE_DEBUG = 1
await Config.get('mysql', 'test')
assert.equal(Config.debug, true)
process.env.NODE_DEBUG = ''
await Config.get('mysql', 'test')
assert.equal(Config.debug, false)
})
})
})
const mysqlTestCfg = {
host: '127.0.0.1',
port: 3306,
user: 'root',
password: 'root',
database: 'nictool',
timezone: '+00:00',
dateStrings: ['DATETIME', 'TIMESTAMP'],
decimalNumbers: true,
}
const httpCfg = {
host: 'localhost',
port: 3000,
cookie: {
clearInvalid: true,
isHttpOnly: false,
isSameSite: 'Strict',
isSecure: false,
name: 'sid-nictool',
password: '^NicTool.Is,The#Best_Dns-Manager$',
path: '/',
ttl: 3600000,
},
jwt: {
key: 'af1b926a5e21f535c4f5b6c42941c4cf',
},
tls: {
cert: null,
key: null,
},
keepAlive: false,
group: 'NicTool',
}