Skip to content

Commit

Permalink
update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Raynos committed Mar 1, 2019
1 parent 8a3bf09 commit 2ec9e7b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 2 additions & 0 deletions tap-snapshots/test-help.js-TAP.test.js
Expand Up @@ -40,6 +40,8 @@ Usage:
-l, --long Expanded output with module list
-c --compliance Expanded output with compliance failures
-s --security Expanded output with security failures
--filter=<value> Expanded output with filtered module list.
filters can be critical, high, medium or low
-j, --json Output report as JSON
-o, --output <filepath> Write JSON report to file
Expand Down
24 changes: 14 additions & 10 deletions tap-snapshots/test-report.js-TAP.test.js
Expand Up @@ -62,22 +62,23 @@ exports[`test/report.js TAP report -c output > report-output-compliance 1`] = `
║ mock-project Report ║
╚═════════════════════╝
32 [38;2;137;161;157mpackages checked[39m
37 [38;2;137;161;157mpackages checked[39m
|||| Low Average module risk
[38;2;255;96;64m![39m 1 security vulnerabilities found across 1 modules
[38;2;255;96;64m![39m 4 security vulnerabilities found across 4 modules
C 0 critical severity
H 1 high severity
[38;2;255;183;38mM[39m 0 medium severity
[38;2;137;161;157mL[39m 0 low severity
[38;2;255;183;38mM[39m 1 medium severity
[38;2;137;161;157mL[39m 2 low severity
|➔ Run \`npm-cli report --security\` for more details
[38;2;255;96;64m![39m 1 noncompliant modules found
[38;2;255;96;64m![39m 2 noncompliant modules found
|➔ Run \`ncm-cli report --compliance\` for more details
 Module Name Risk License Security
┌──────────────────────────────────────────┬────────────┬───────────────────────┬───────────────┐
│ ms @ 0.7.1 │ |||| High │ X UNKNOWN │ X 1L │
│ left-pad @ 1.3.0 │ |||| Med  │ X WTFPL │ ✓ 0 │
└──────────────────────────────────────────┴────────────┴───────────────────────┴───────────────┘
Expand Down Expand Up @@ -147,23 +148,26 @@ exports[`test/report.js TAP report -s output > report-output-security 1`] = `
║ mock-project Report ║
╚═════════════════════╝
32 [38;2;137;161;157mpackages checked[39m
37 [38;2;137;161;157mpackages checked[39m
|||| Low Average module risk
[38;2;255;96;64m![39m 1 security vulnerabilities found across 1 modules
[38;2;255;96;64m![39m 4 security vulnerabilities found across 4 modules
C 0 critical severity
H 1 high severity
[38;2;255;183;38mM[39m 0 medium severity
[38;2;137;161;157mL[39m 0 low severity
[38;2;255;183;38mM[39m 1 medium severity
[38;2;137;161;157mL[39m 2 low severity
|➔ Run \`npm-cli report --security\` for more details
[38;2;255;96;64m![39m 1 noncompliant modules found
[38;2;255;96;64m![39m 2 noncompliant modules found
|➔ Run \`ncm-cli report --compliance\` for more details
 Module Name Risk License Security
┌──────────────────────────────────────────┬────────────┬───────────────────────┬───────────────┐
│ handlebars @ 4.0.5 │ |||| High │ ✓ MIT │ X 1H │
│ ms @ 0.7.1 │ |||| High │ X UNKNOWN │ X 1L │
│ brace-expansion @ 1.1.2 │ |||| Med  │ ✓ MIT │ X 1M │
│ debug @ 2.2.0 │ |||| Med  │ ✓ MIT │ X 1L │
└──────────────────────────────────────────┴────────────┴───────────────────────┴───────────────┘
`
Expand Down
10 changes: 5 additions & 5 deletions test/report.js
Expand Up @@ -15,7 +15,7 @@ test('report output matches snapshot', (t) =>
t.notOk(stderr)
t.matchSnapshot(stdout, 'report-output')
t.ok(/mock-project Report/.test(stdout))
t.ok(/32 .+packages checked/.test(stdout))
t.ok(/37 .+packages checked/.test(stdout))
t.notOk(/has-flag @ 3.0.0/.test(stdout))

const out = stdout.toString()
Expand Down Expand Up @@ -53,10 +53,10 @@ test('report -c output', (t) =>
t.matchSnapshot(stdout, 'report-output-compliance')

const out = stdout.toString()
t.ok(/1 noncompliant modules found/.test(out))
t.ok(/2 noncompliant modules found/.test(out))
t.ok(/left-pad @ 1.3.0/.test(out))
t.ok(/WTFPL/.test(out))
t.ok(/1 security vulnerabilities found/.test(out))
t.ok(/4 security vulnerabilities found/.test(out))
t.end()
})
)
Expand Down Expand Up @@ -113,8 +113,8 @@ test('report -s output', (t) =>
t.matchSnapshot(stdout, 'report-output-security')

const out = stdout.toString()
t.ok(/1 noncompliant modules found/.test(out))
t.ok(/1 security vulnerabilities found/.test(out))
t.ok(/2 noncompliant modules found/.test(out))
t.ok(/4 security vulnerabilities found/.test(out))
t.ok(/handlebars @ 4.0.5/.test(out))
t.ok(/1H/.test(out))
t.end()
Expand Down

0 comments on commit 2ec9e7b

Please sign in to comment.