@@ -2,32 +2,39 @@ import { describe, expect, it, vi } from "vitest";
2
2
3
3
import { removeDependencies } from "./packages.js" ;
4
4
5
- const mock$ = vi . fn ( ) ;
5
+ const mockExecaCommand = vi . fn ( ) ;
6
6
7
7
vi . mock ( "execa" , ( ) => ( {
8
- get $ ( ) {
9
- return mock$ ;
8
+ get execaCommand ( ) {
9
+ return mockExecaCommand ;
10
10
} ,
11
11
} ) ) ;
12
12
13
13
describe ( "removeDependencies" , ( ) => {
14
+ it ( "removes all packages that already exist when all already exist" , async ( ) => {
15
+ await removeDependencies ( [ "one" , "two" ] , {
16
+ one : "1.2.3" ,
17
+ two : "4.5.6" ,
18
+ } ) ;
19
+
20
+ expect ( mockExecaCommand . mock . calls ) . toMatchInlineSnapshot ( `
21
+ [
22
+ [
23
+ "pnpm remove one two",
24
+ ],
25
+ ]
26
+ ` ) ;
27
+ } ) ;
28
+
14
29
it ( "removes only packages that already exist when some don't exist" , async ( ) => {
15
30
await removeDependencies ( [ "exists" , "missing" ] , {
16
31
exists : "1.2.3" ,
17
32
} ) ;
18
33
19
- expect ( mock$ . mock . calls ) . toMatchInlineSnapshot ( `
34
+ expect ( mockExecaCommand . mock . calls ) . toMatchInlineSnapshot ( `
20
35
[
21
36
[
22
- [
23
- "pnpm remove ",
24
- "",
25
- "",
26
- ],
27
- [
28
- "exists",
29
- ],
30
- "",
37
+ "pnpm remove exists",
31
38
],
32
39
]
33
40
` ) ;
@@ -42,18 +49,10 @@ describe("removeDependencies", () => {
42
49
"-D" ,
43
50
) ;
44
51
45
- expect ( mock$ . mock . calls ) . toMatchInlineSnapshot ( `
52
+ expect ( mockExecaCommand . mock . calls ) . toMatchInlineSnapshot ( `
46
53
[
47
54
[
48
- [
49
- "pnpm remove ",
50
- "",
51
- "",
52
- ],
53
- [
54
- "exists",
55
- ],
56
- " -D",
55
+ "pnpm remove exists -D",
57
56
],
58
57
]
59
58
` ) ;
@@ -62,6 +61,6 @@ describe("removeDependencies", () => {
62
61
it ( "does nothing when no packages already exist" , async ( ) => {
63
62
await removeDependencies ( [ "missing" ] ) ;
64
63
65
- expect ( mock$ . mock . calls ) . toMatchInlineSnapshot ( "[]" ) ;
64
+ expect ( mockExecaCommand . mock . calls ) . toMatchInlineSnapshot ( "[]" ) ;
66
65
} ) ;
67
66
} ) ;
0 commit comments