|
1 | | -const assert = require('node:assert/strict') |
2 | | -const { describe, it } = require('node:test') |
| 1 | +import assert from 'node:assert/strict' |
| 2 | +import { describe, it } from 'node:test' |
3 | 3 |
|
4 | | -const config = require('./config') |
| 4 | +import Config from './config.js' |
5 | 5 |
|
6 | | -describe('config', function () { |
7 | | - describe('get', function () { |
8 | | - it(`loads mysql test config`, async function () { |
9 | | - const cfg = await config.get('mysql', 'test') |
| 6 | +describe('config', () => { |
| 7 | + describe('get', () => { |
| 8 | + it(`loads mysql test config`, async () => { |
| 9 | + const cfg = await Config.get('mysql', 'test') |
10 | 10 | assert.deepEqual(cfg, mysqlTestCfg) |
11 | 11 | }) |
12 | 12 |
|
13 | | - it(`loads mysql test config syncronously`, function () { |
14 | | - const cfg = config.getSync('mysql', 'test') |
| 13 | + it(`loads mysql test config syncronously`, () => { |
| 14 | + const cfg = Config.getSync('mysql', 'test') |
15 | 15 | assert.deepEqual(cfg, mysqlTestCfg) |
16 | 16 | }) |
17 | 17 |
|
18 | | - it(`loads mysql cov config`, async function () { |
19 | | - const cfg = await config.get('mysql', 'cov') |
| 18 | + it(`loads mysql cov config`, async () => { |
| 19 | + const cfg = await Config.get('mysql', 'cov') |
20 | 20 | assert.deepEqual(cfg, mysqlTestCfg) |
21 | 21 | }) |
22 | 22 |
|
23 | | - it(`loads mysql cov config (from cache)`, async function () { |
| 23 | + it(`loads mysql cov config (from cache)`, async () => { |
24 | 24 | process.env.NODE_DEBUG = 1 |
25 | | - const cfg = await config.get('mysql', 'cov') |
| 25 | + const cfg = await Config.get('mysql', 'cov') |
26 | 26 | assert.deepEqual(cfg, mysqlTestCfg) |
27 | 27 | process.env.NODE_DEBUG = '' |
28 | 28 | }) |
29 | 29 |
|
30 | | - it(`loads session test config`, async function () { |
31 | | - const cfg = await config.get('session', 'test') |
| 30 | + it(`loads session test config`, async () => { |
| 31 | + const cfg = await Config.get('session', 'test') |
32 | 32 | assert.deepEqual(cfg, sessCfg) |
33 | 33 | }) |
34 | 34 |
|
35 | | - it(`loads session test config syncronously`, function () { |
36 | | - const cfg = config.getSync('session', 'test') |
| 35 | + it(`loads session test config syncronously`, () => { |
| 36 | + const cfg = Config.getSync('session', 'test') |
37 | 37 | assert.deepEqual(cfg, sessCfg) |
38 | 38 | }) |
39 | 39 |
|
40 | | - it(`loads http test config syncronously`, function () { |
41 | | - const cfg = config.getSync('http', 'test') |
| 40 | + it(`loads http test config syncronously`, () => { |
| 41 | + const cfg = Config.getSync('http', 'test') |
42 | 42 | assert.deepEqual(cfg, httpCfg) |
43 | 43 | }) |
| 44 | + |
| 45 | + it(`detects NODE_DEBUG env`, async () => { |
| 46 | + process.env.NODE_DEBUG = 1 |
| 47 | + let cfg = await Config.get('mysql', 'test') |
| 48 | + assert.equal(Config.debug, true) |
| 49 | + |
| 50 | + process.env.NODE_DEBUG = '' |
| 51 | + cfg = await Config.get('mysql', 'test') |
| 52 | + assert.equal(Config.debug, false) |
| 53 | + |
| 54 | + cfg = await Config.get('mysql', 'test') |
| 55 | + assert.equal(cfg.user, 'root') |
| 56 | + }) |
44 | 57 | }) |
45 | 58 | }) |
46 | 59 |
|
|
0 commit comments