|
1 |
| -import { system, filesystem } from 'gluegun' |
| 1 | +import { filesystem, system } from 'gluegun'; |
| 2 | +import { PackageJSON } from 'gluegun/build/types/toolbox/meta-types'; |
2 | 3 |
|
3 | 4 | const src = filesystem.path(__dirname, '..')
|
4 | 5 |
|
5 | 6 | const cli = async (cmd) =>
|
6 | 7 | system.run('node ' + filesystem.path(src, 'bin', 'ngx-devs-cli') + ` ${cmd}`)
|
7 | 8 |
|
8 |
| -test('outputs version', async () => { |
9 |
| - const output = await cli('--version') |
10 |
| - expect(output).toContain('0.0.1') |
11 |
| -}) |
12 |
| - |
13 |
| -test('outputs help', async () => { |
14 |
| - const output = await cli('--help') |
15 |
| - expect(output).toContain('0.0.1') |
16 |
| -}) |
17 |
| - |
18 |
| -test('generates file', async () => { |
19 |
| - const output = await cli('generate foo') |
20 |
| - |
21 |
| - expect(output).toContain('Generated file at models/foo-model.ts') |
22 |
| - const foomodel = filesystem.read('models/foo-model.ts') |
| 9 | +describe('[Commands: version]', () => { |
| 10 | + test('should output package.json version', async () => { |
| 11 | + const packageJson: PackageJSON = filesystem.read( |
| 12 | + `${src}/package.json`, |
| 13 | + 'json' |
| 14 | + ) |
23 | 15 |
|
24 |
| - expect(foomodel).toContain(`module.exports = {`) |
25 |
| - expect(foomodel).toContain(`name: 'foo'`) |
| 16 | + const expectedVersion = packageJson.version |
| 17 | + const output = await cli('--version') |
26 | 18 |
|
27 |
| - // cleanup artifact |
28 |
| - filesystem.remove('models') |
| 19 | + expect(output).toContain(expectedVersion) |
| 20 | + }) |
29 | 21 | })
|
0 commit comments