-
-
Notifications
You must be signed in to change notification settings - Fork 189
/
config-make.spec.js
50 lines (44 loc) · 1.31 KB
/
config-make.spec.js
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
'use strict'
/*
* adonis-lucid
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
const test = require('japa')
const ace = require('@adonisjs/ace')
const fs = require('fs-extra')
const path = require('path')
const { ioc } = require('@adonisjs/fold')
const { setupResolver, Helpers } = require('@adonisjs/sink')
const MakeConfig = require('../../commands/MakeConfig')
test.group('Make Config', (group) => {
group.before(async () => {
ioc.bind('Adonis/Src/Helpers', () => {
return new Helpers(path.join(__dirname))
})
setupResolver()
})
group.after(async () => {
try {
await fs.remove(path.join(__dirname, 'config'))
} catch (error) {
if (process.platform !== 'win32' || error.code !== 'EBUSY') {
throw error
}
}
}).timeout(0)
test('create config file', async (assert) => {
ace.addCommand(MakeConfig)
const result = await ace.call('config:database')
const exists = await fs.pathExists(result)
assert.isTrue(exists)
})
test('echo config file to console', async (assert) => {
ace.addCommand(MakeConfig)
const result = await ace.call('config:database', {}, { echo: true })
assert.equal(result, 'echoed')
})
})