Skip to content

Commit 5bb5a02

Browse files
committed
🧪 test(commands/version): ensure outputs package.json version
1 parent 76882a8 commit 5bb5a02

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

__tests__/cli-integration.test.ts

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
1-
import { system, filesystem } from 'gluegun'
1+
import { filesystem, system } from 'gluegun';
2+
import { PackageJSON } from 'gluegun/build/types/toolbox/meta-types';
23

34
const src = filesystem.path(__dirname, '..')
45

56
const cli = async (cmd) =>
67
system.run('node ' + filesystem.path(src, 'bin', 'ngx-devs-cli') + ` ${cmd}`)
78

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+
)
2315

24-
expect(foomodel).toContain(`module.exports = {`)
25-
expect(foomodel).toContain(`name: 'foo'`)
16+
const expectedVersion = packageJson.version
17+
const output = await cli('--version')
2618

27-
// cleanup artifact
28-
filesystem.remove('models')
19+
expect(output).toContain(expectedVersion)
20+
})
2921
})

0 commit comments

Comments
 (0)