Skip to content

Commit d68b6af

Browse files
committed
fix tests
1 parent df30019 commit d68b6af

File tree

47 files changed

+296
-213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+296
-213
lines changed

integration-tests/append-patches/__snapshots__/append-patches.test.ts.snap

+5
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,17 @@ END SNAPSHOT"
8282

8383
exports[`Test append-patches: 07: patch-package fails when a patch in the sequence is invalid 1`] = `
8484
"SNAPSHOT: patch-package fails when a patch in the sequence is invalid
85+
patch-package 0.0.0
86+
• Creating temporary folder
87+
• Installing [email protected] with npm
88+
• Diffing your files with clean files
8589
Failed to apply patch left-pad+1.3.0+001+FirstPatch.patch to left-pad
8690
END SNAPSHOT"
8791
`;
8892

8993
exports[`Test append-patches: 08: --append is not compatible with --create-issue 1`] = `
9094
"SNAPSHOT: --append is not compatible with --create-issue
95+
patch-package 0.0.0
9196
--create-issue is not compatible with --append.
9297
END SNAPSHOT"
9398
`;

integration-tests/append-patches/append-patches.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ echo "END SNAPSHOT"
7171
echo "if one of the patches in the sequence is invalid, the sequence is not applied"
7272
npx replace 'use strict' 'use bananas' patches/*FirstPatch.patch
7373

74-
(>&2 echo "SNAPSHOT: patch-package fails when a patch in the sequence is invalid")
74+
echo "SNAPSHOT: patch-package fails when a patch in the sequence is invalid"
7575
if patch-package left-pad --append 'Bananas' ; then
7676
exit 1
7777
fi
78-
(>&2 echo "END SNAPSHOT")
78+
echo "END SNAPSHOT"
7979

80-
(>&2 echo "SNAPSHOT: --append is not compatible with --create-issue")
80+
echo "SNAPSHOT: --append is not compatible with --create-issue"
8181
if patch-package left-pad --append 'Bananas' --create-issue ; then
8282
exit 1
8383
fi
84-
(>&2 echo "END SNAPSHOT")
84+
echo "END SNAPSHOT"

integration-tests/apply-multiple-patches/__snapshots__/apply-multiple-patches.test.ts.snap

+51-32
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ END SNAPSHOT"
1313
exports[`Test apply-multiple-patches: 01: patch-package stores a state file to list the patches that have been applied 1`] = `
1414
"SNAPSHOT: patch-package stores a state file to list the patches that have been applied
1515
{
16+
\\"isRebasing\\": false,
1617
\\"patches\\": [
1718
{
1819
\\"didApply\\": true,
@@ -30,62 +31,80 @@ exports[`Test apply-multiple-patches: 01: patch-package stores a state file to l
3031
\\"patchFilename\\": \\"left-pad+1.3.0+004+goodbye.patch\\"
3132
}
3233
],
33-
\\"version\\": 0
34+
\\"version\\": 1
3435
}END SNAPSHOT"
3536
`;
3637

37-
exports[`Test apply-multiple-patches: 02: patch-package only applies the first patch if the second of three is invalid 1`] = `
38+
exports[`Test apply-multiple-patches: 02: patch-package fails when a patch in the sequence is invalid 1`] = `
39+
"SNAPSHOT: patch-package fails when a patch in the sequence is invalid
40+
patch-package 0.0.0
41+
Applying patches...
42+
[email protected] (1 hello) ✔
43+
44+
⛔ ERROR
45+
46+
Failed to apply patch file left-pad+1.3.0+002+broken.patch.
47+
48+
If this patch file is no longer useful, delete it and run
49+
50+
patch-package
51+
52+
Otherwise you should open node_modules/left-pad, manually apply the changes from the patch file, and run
53+
54+
patch-package left-pad
55+
56+
to update the patch file.
57+
58+
END SNAPSHOT"
59+
`;
60+
61+
exports[`Test apply-multiple-patches: 03: patch-package only applies the first patch if the second of three is invalid 1`] = `
3862
"SNAPSHOT: patch-package only applies the first patch if the second of three is invalid
3963
patch-package 0.0.0
4064
Applying patches...
4165
[email protected] (1 hello) ✔
66+
67+
⛔ ERROR
68+
69+
Failed to apply patch file left-pad+1.3.0+002+broken.patch.
70+
71+
If this patch file is no longer useful, delete it and run
72+
73+
patch-package
74+
75+
Otherwise you should open node_modules/left-pad, manually apply the changes from the patch file, and run
76+
77+
patch-package left-pad
78+
79+
to update the patch file.
80+
4281
END SNAPSHOT"
4382
`;
4483

45-
exports[`Test apply-multiple-patches: 03: patch-package stores a state file of only the first patch if there was an error 1`] = `
84+
exports[`Test apply-multiple-patches: 04: patch-package stores a state file of only the first patch if there was an error 1`] = `
4685
"SNAPSHOT: patch-package stores a state file of only the first patch if there was an error
4786
{
87+
\\"isRebasing\\": true,
4888
\\"patches\\": [
4989
{
5090
\\"didApply\\": true,
5191
\\"patchContentHash\\": \\"404c604ed830db6a0605f86cb9165ced136848f70986b23bf877bcf38968c1c9\\",
5292
\\"patchFilename\\": \\"left-pad+1.3.0+001+hello.patch\\"
93+
},
94+
{
95+
\\"didApply\\": false,
96+
\\"patchContentHash\\": \\"9c5c141e2578b4178fd57dd7726488c2f7eab32e23a7848701da29dcb371b9f2\\",
97+
\\"patchFilename\\": \\"left-pad+1.3.0+002+broken.patch\\"
5398
}
5499
],
55-
\\"version\\": 0
100+
\\"version\\": 1
56101
}END SNAPSHOT"
57102
`;
58103

59-
exports[`Test apply-multiple-patches: 04: patch-package fails when a patch in the sequence is invalid 1`] = `
60-
"SNAPSHOT: patch-package fails when a patch in the sequence is invalid
61-
62-
**ERROR** Failed to apply patch for package left-pad at path
63-
64-
node_modules/left-pad
65-
66-
This error was caused because patch-package cannot apply the following patch file:
67-
68-
patches/left-pad+1.3.0+002+broken.patch
69-
70-
Try removing node_modules and trying again. If that doesn't work, maybe there was
71-
an accidental change made to the patch file? Try recreating it by manually
72-
editing the appropriate files and running:
73-
74-
patch-package left-pad
75-
76-
If that doesn't work, then it's a bug in patch-package, so please submit a bug
77-
report. Thanks!
78-
79-
https://github.com/ds300/patch-package/issues
80-
81-
82-
---
83-
patch-package finished with 1 error(s).
84-
END SNAPSHOT"
85-
`;
86-
87104
exports[`Test apply-multiple-patches: 05: patch-package fails when a patch file is removed 1`] = `
88105
"SNAPSHOT: patch-package fails when a patch file is removed
106+
patch-package 0.0.0
107+
Applying patches...
89108
Error: The patches for left-pad have changed. You should reinstall your node_modules folder to make sure the package is up to date
90109
END SNAPSHOT"
91110
`;

integration-tests/apply-multiple-patches/apply-multiple-patches.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ cp *broken.patch patches/
2626

2727
rm -rf node_modules
2828
npm install
29-
(>&2 echo "SNAPSHOT: patch-package fails when a patch in the sequence is invalid")
29+
echo "SNAPSHOT: patch-package fails when a patch in the sequence is invalid"
3030
if patch-package
3131
then
3232
exit 1
3333
fi
34-
(>&2 echo "END SNAPSHOT")
34+
echo "END SNAPSHOT"
3535

3636

3737
echo "SNAPSHOT: patch-package only applies the first patch if the second of three is invalid"
@@ -47,9 +47,9 @@ echo "END SNAPSHOT"
4747

4848

4949
rm patches/*hello.patch
50-
(>&2 echo "SNAPSHOT: patch-package fails when a patch file is removed")
50+
echo "SNAPSHOT: patch-package fails when a patch file is removed"
5151
if patch-package
5252
then
5353
exit 1
5454
fi
55-
(>&2 echo "END SNAPSHOT")
55+
echo "END SNAPSHOT"

integration-tests/broken-patch-file/__snapshots__/broken-patch-file.test.ts.snap

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
exports[`Test broken-patch-file: 00: patch-package fails when patch file is invalid 1`] = `
44
"SNAPSHOT: patch-package fails when patch file is invalid
5+
patch-package 0.0.0
6+
Applying patches...
57
68
**ERROR** Failed to apply patch for package left-pad at path
79

integration-tests/broken-patch-file/broken-patch-file.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ echo "add patch-package"
55
yarn add $1
66
alias patch-package=./node_modules/.bin/patch-package
77

8-
(>&2 echo "SNAPSHOT: patch-package fails when patch file is invalid")
8+
echo "SNAPSHOT: patch-package fails when patch file is invalid"
99
if patch-package
1010
then
1111
exit 1
1212
fi
13-
(>&2 echo "END SNAPSHOT")
13+
echo "END SNAPSHOT"

integration-tests/collate-errors/__snapshots__/collate-errors.test.ts.snap

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22

33
exports[`Test collate-errors: 00: left-pad, lodash, and zfs apply 1`] = `
44
"SNAPSHOT: left-pad, lodash, and zfs apply
5+
SNAPSHOT: underscore does not apply, left-pad warns
56
patch-package 0.0.0
67
Applying patches...
78
89
910
10-
END SNAPSHOT"
11-
`;
12-
13-
exports[`Test collate-errors: 01: underscore does not apply, left-pad warns 1`] = `
14-
"SNAPSHOT: underscore does not apply, left-pad warns
1511
1612
Warning: patch-package detected a patch file version mismatch
1713

integration-tests/collate-errors/collate-errors.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ yarn add $1
66
alias patch-package=./node_modules/.bin/patch-package
77

88
echo "SNAPSHOT: left-pad, lodash, and zfs apply"
9-
(>&2 echo "SNAPSHOT: underscore does not apply, left-pad warns")
9+
echo "SNAPSHOT: underscore does not apply, left-pad warns"
1010
if patch-package;
1111
then
1212
exit 1
1313
fi
14-
(>&2 echo "END SNAPSHOT")
14+
echo "END SNAPSHOT"
1515
echo "END SNAPSHOT"

integration-tests/dev-only-patches/__snapshots__/dev-only-patches.test.ts.snap

+12-8
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,12 @@ Skipping dev-only [email protected]
99
END SNAPSHOT"
1010
`;
1111

12-
exports[`Test dev-only-patches: 01: fake-package should be skipped 1`] = `
13-
"SNAPSHOT: fake-package should be skipped
12+
exports[`Test dev-only-patches: 01: patch-package fails to find fake-package 1`] = `
13+
"SNAPSHOT: patch-package fails to find fake-package
1414
patch-package 0.0.0
1515
Applying patches...
16-
Skipping dev-only [email protected]
1716
1817
Skipping dev-only [email protected]
19-
END SNAPSHOT"
20-
`;
21-
22-
exports[`Test dev-only-patches: 02: patch-package fails to find fake-package 1`] = `
23-
"SNAPSHOT: patch-package fails to find fake-package
2418
Error: Patch file found for package fake-package which is not present at node_modules/fake-package
2519
2620
If this package is a dev dependency, rename the patch file to
@@ -31,3 +25,13 @@ Error: Patch file found for package fake-package which is not present at node_mo
3125
patch-package finished with 1 error(s).
3226
END SNAPSHOT"
3327
`;
28+
29+
exports[`Test dev-only-patches: 02: fake-package should be skipped 1`] = `
30+
"SNAPSHOT: fake-package should be skipped
31+
patch-package 0.0.0
32+
Applying patches...
33+
Skipping dev-only [email protected]
34+
35+
Skipping dev-only [email protected]
36+
END SNAPSHOT"
37+
`;

integration-tests/dev-only-patches/dev-only-patches.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ echo "END SNAPSHOT"
1616
echo "create fake-package+3.0.0.patch"
1717
cp patches/slash+3.0.0.patch patches/fake-package+3.0.0.patch
1818

19-
(>&2 echo "SNAPSHOT: patch-package fails to find fake-package")
19+
echo "SNAPSHOT: patch-package fails to find fake-package"
2020
if patch-package
2121
then
2222
exit 1
2323
fi
24-
(>&2 echo "END SNAPSHOT")
24+
echo "END SNAPSHOT"
2525

2626
echo "rename fake-package patch file to .dev.patch"
2727
mv patches/fake-package+3.0.0.patch patches/fake-package+3.0.0.dev.patch

integration-tests/error-on-fail/__snapshots__/error-on-fail.test.ts.snap

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
exports[`Test error-on-fail: 00: at dev time patch-package fails but returns 0 1`] = `
44
"SNAPSHOT: at dev time patch-package fails but returns 0
5+
patch-package 0.0.0
6+
Applying patches...
57
68
**ERROR** Failed to apply patch for package left-pad at path
79

integration-tests/error-on-fail/error-on-fail.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ alias patch-package=./node_modules/.bin/patch-package
88
export NODE_ENV="development"
99
export CI="true"
1010

11-
(>&2 echo "SNAPSHOT: at dev time patch-package fails but returns 0")
11+
echo "SNAPSHOT: at dev time patch-package fails but returns 0"
1212
if ! patch-package;
1313
then
1414
exit 1
1515
fi
16-
(>&2 echo "END SNAPSHOT")
16+
echo "END SNAPSHOT"
1717

1818
echo "adding --error-on-fail forces patch-package to return 1 at dev time"
1919
if patch-package --error-on-fail;

integration-tests/error-on-warn/__snapshots__/error-on-warn.test.ts.snap

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
exports[`Test error-on-warn: 00: at dev time patch-package warns but returns 0 1`] = `
44
"SNAPSHOT: at dev time patch-package warns but returns 0
5+
patch-package 0.0.0
6+
Applying patches...
7+
58
69
Warning: patch-package detected a patch file version mismatch
710

integration-tests/error-on-warn/error-on-warn.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ alias patch-package=./node_modules/.bin/patch-package
88
export NODE_ENV="development"
99
export CI=""
1010

11-
(>&2 echo "SNAPSHOT: at dev time patch-package warns but returns 0")
11+
echo "SNAPSHOT: at dev time patch-package warns but returns 0"
1212
if ! patch-package;
1313
then
1414
exit 1
1515
fi
16-
(>&2 echo "END SNAPSHOT")
16+
echo "END SNAPSHOT"
1717

1818
echo "adding --error-on-warn forces patch-package to return 1 at dev time"
1919
if patch-package --error-on-warn;

integration-tests/fails-when-no-package/__snapshots__/fails-when-no-package.test.ts.snap

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
exports[`Test fails-when-no-package: 00: no package present failure 1`] = `
44
"SNAPSHOT: no package present failure
5+
patch-package 0.0.0
6+
Applying patches...
57
Error: Patch file found for package left-pad which is not present at node_modules/left-pad
68
---
79
patch-package finished with 1 error(s).

integration-tests/fails-when-no-package/fails-when-no-package.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ echo "add patch-package"
55
yarn add $1
66
alias patch-package=./node_modules/.bin/patch-package
77

8-
(>&2 echo "SNAPSHOT: no package present failure")
8+
echo "SNAPSHOT: no package present failure"
99
if patch-package; then
1010
exit 1
1111
fi
12-
(>&2 echo "END SNAPSHOT")
12+
echo "END SNAPSHOT"

integration-tests/ignore-whitespace/__snapshots__/ignore-whitespace.test.ts.snap

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Test ignore-whitespace: 00: line a changed 1`] = `
3+
exports[`Test ignore-whitespace: 00: empty changeset when adding whitespace 1`] = `
4+
"SNAPSHOT: empty changeset when adding whitespace
5+
patch-package 0.0.0
6+
• Creating temporary folder
7+
• Installing [email protected] with yarn
8+
• Diffing your files with clean files
9+
⁉️ Not creating patch file for package 'alphabet'
10+
⁉️ There don't appear to be any changes.
11+
END SNAPSHOT"
12+
`;
13+
14+
exports[`Test ignore-whitespace: 01: line a changed 1`] = `
415
"SNAPSHOT: line a changed
516
diff --git a/node_modules/alphabet/index.js b/node_modules/alphabet/index.js
617
index 7811d3b..454414b 100644
@@ -14,10 +25,3 @@ index 7811d3b..454414b 100644
1425
// d
1526
END SNAPSHOT"
1627
`;
17-
18-
exports[`Test ignore-whitespace: 01: empty changeset when adding whitespace 1`] = `
19-
"SNAPSHOT: empty changeset when adding whitespace
20-
⁉️ Not creating patch file for package 'alphabet'
21-
⁉️ There don't appear to be any changes.
22-
END SNAPSHOT"
23-
`;

0 commit comments

Comments
 (0)