Skip to content

Commit b8d6089

Browse files
committed
chore: refactor pack tests
Uses the real npm object and doesn't mock anything. PR-URL: #4018 Credit: @wraithgar Close: #4018 Reviewed-by: @lukekarrys
1 parent 2039184 commit b8d6089

File tree

4 files changed

+197
-353
lines changed

4 files changed

+197
-353
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/* IMPORTANT
2+
* This snapshot file is auto-generated, but designed for humans.
3+
* It should be checked into source control and tracked carefully.
4+
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
5+
* Make sure to inspect the output below. Do not ignore changes!
6+
*/
7+
'use strict'
8+
exports[`test/lib/commands/pack.js TAP dry run > logs pack contents 1`] = `
9+
Array [
10+
undefined,
11+
"package: test-package@1.0.0",
12+
undefined,
13+
"41B package.json",
14+
undefined,
15+
String(
16+
name: test-package
17+
version: 1.0.0
18+
filename: test-package-1.0.0.tgz
19+
package size: 136 B
20+
unpacked size: 41 B
21+
shasum: a92a0679a70a450f14f98a468756948a679e4107
22+
integrity: sha512-Gka9ZV/Bryxky[...]LgMJ+0F+FhXMA==
23+
total files: 1
24+
),
25+
"",
26+
]
27+
`
28+
29+
exports[`test/lib/commands/pack.js TAP should log output as valid json > logs pack contents 1`] = `
30+
Array []
31+
`
32+
33+
exports[`test/lib/commands/pack.js TAP should log output as valid json > outputs as json 1`] = `
34+
Array [
35+
Array [
36+
Object {
37+
"bundled": Array [],
38+
"entryCount": 1,
39+
"filename": "test-package-1.0.0.tgz",
40+
"files": Array [
41+
Object {
42+
"mode": 420,
43+
"path": "package.json",
44+
"size": 41,
45+
},
46+
],
47+
"id": "test-package@1.0.0",
48+
"integrity": "sha512-Gka9ZV/BryxkypfvMpTvLfaJE1AUi7PK1EAbYqnVzqtucf6QvUK4CFsLVzagY1GwZVx2T1jwWLgMJ+0F+FhXMA==",
49+
"name": "test-package",
50+
"shasum": "a92a0679a70a450f14f98a468756948a679e4107",
51+
"size": 136,
52+
"unpackedSize": 41,
53+
"version": "1.0.0",
54+
},
55+
],
56+
]
57+
`
58+
59+
exports[`test/lib/commands/pack.js TAP should pack current directory with no arguments > logs pack contents 1`] = `
60+
Array [
61+
undefined,
62+
"package: test-package@1.0.0",
63+
undefined,
64+
"41B package.json",
65+
undefined,
66+
String(
67+
name: test-package
68+
version: 1.0.0
69+
filename: test-package-1.0.0.tgz
70+
package size: 136 B
71+
unpacked size: 41 B
72+
shasum: a92a0679a70a450f14f98a468756948a679e4107
73+
integrity: sha512-Gka9ZV/Bryxky[...]LgMJ+0F+FhXMA==
74+
total files: 1
75+
),
76+
"",
77+
]
78+
`

test/fixtures/mock-npm.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const RealMockNpm = (t, otherMocks = {}) => {
2525
mock.joinedOutput = () => {
2626
return mock.outputs.map(o => o.join(' ')).join('\n')
2727
}
28+
mock.filteredLogs = title => mock.logs.filter(([t]) => t === title).map(([, , msg]) => msg)
2829
const Npm = t.mock('../../lib/npm.js', otherMocks)
2930
class MockNpm extends Npm {
3031
constructor () {

0 commit comments

Comments
 (0)