Skip to content

Commit

Permalink
test: add test cases for future regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
lirantal committed Aug 28, 2023
1 parent ed61024 commit 7e1d41d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions packages/lockfile-lint/__tests__/cli.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const semver = require('semver')
const path = require('path')
// eslint-disable-next-line security/detect-child-process
const childProcess = require('child_process')
Expand Down Expand Up @@ -42,6 +43,21 @@ describe('CLI tests', () => {
})
})

test('Checking for version number should be semver compatible and exit with no errors', done => {
const process = childProcess.spawn('node', [cliExecPath, '--version'])

let output = ''
process.stdout.on('data', chunk => {
output += chunk
})

process.on('close', exit => {
expect(semver.valid(output.trim())).toBeTruthy()
expect(exit).toBe(0)
done()
})
})

test('Linting a file that has wrong host should display an error message and use exit code 1', done => {
const process = childProcess.spawn('node', [
cliExecPath,
Expand Down
3 changes: 2 additions & 1 deletion packages/lockfile-lint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"eslint-plugin-standard": "^4.1.0",
"jest": "29.6.2",
"open-cli": "^7.2.0",
"prettier-standard": "16.4.1"
"prettier-standard": "16.4.1",
"semver": "^7.5.4"
},
"jest": {
"testEnvironment": "node",
Expand Down

0 comments on commit 7e1d41d

Please sign in to comment.