@@ -9,11 +9,11 @@ describe('package-manifest', () => {
9
9
it ( 'reads a minimal package manifest, expanding it by filling in values for optional fields' , async ( ) => {
10
10
await withSandbox ( async ( sandbox ) => {
11
11
const manifestPath = path . join ( sandbox . directoryPath , 'package.json' ) ;
12
- const unvalidatedManifest = {
12
+ const unvalidated = {
13
13
name : 'foo' ,
14
14
version : '1.2.3' ,
15
15
} ;
16
- const validatedManifest = {
16
+ const validated = {
17
17
name : 'foo' ,
18
18
version : new SemVer ( '1.2.3' ) ,
19
19
workspaces : [ ] ,
@@ -24,27 +24,24 @@ describe('package-manifest', () => {
24
24
optionalDependencies : { } ,
25
25
peerDependencies : { } ,
26
26
} ;
27
- await fs . promises . writeFile (
28
- manifestPath ,
29
- JSON . stringify ( unvalidatedManifest ) ,
30
- ) ;
27
+ await fs . promises . writeFile ( manifestPath , JSON . stringify ( unvalidated ) ) ;
31
28
32
29
expect ( await readPackageManifest ( manifestPath ) ) . toStrictEqual ( {
33
- unvalidatedManifest ,
34
- validatedManifest ,
30
+ unvalidated ,
31
+ validated ,
35
32
} ) ;
36
33
} ) ;
37
34
} ) ;
38
35
39
36
it ( 'reads a package manifest where "private" is true' , async ( ) => {
40
37
await withSandbox ( async ( sandbox ) => {
41
38
const manifestPath = path . join ( sandbox . directoryPath , 'package.json' ) ;
42
- const unvalidatedManifest = {
39
+ const unvalidated = {
43
40
name : 'foo' ,
44
41
version : '1.2.3' ,
45
42
private : true ,
46
43
} ;
47
- const validatedManifest = {
44
+ const validated = {
48
45
name : 'foo' ,
49
46
version : new SemVer ( '1.2.3' ) ,
50
47
workspaces : [ ] ,
@@ -55,27 +52,24 @@ describe('package-manifest', () => {
55
52
optionalDependencies : { } ,
56
53
peerDependencies : { } ,
57
54
} ;
58
- await fs . promises . writeFile (
59
- manifestPath ,
60
- JSON . stringify ( unvalidatedManifest ) ,
61
- ) ;
55
+ await fs . promises . writeFile ( manifestPath , JSON . stringify ( unvalidated ) ) ;
62
56
63
57
expect ( await readPackageManifest ( manifestPath ) ) . toStrictEqual ( {
64
- unvalidatedManifest ,
65
- validatedManifest ,
58
+ unvalidated ,
59
+ validated ,
66
60
} ) ;
67
61
} ) ;
68
62
} ) ;
69
63
70
64
it ( 'reads a package manifest where "private" is false' , async ( ) => {
71
65
await withSandbox ( async ( sandbox ) => {
72
66
const manifestPath = path . join ( sandbox . directoryPath , 'package.json' ) ;
73
- const unvalidatedManifest = {
67
+ const unvalidated = {
74
68
name : 'foo' ,
75
69
version : '1.2.3' ,
76
70
private : false ,
77
71
} ;
78
- const validatedManifest = {
72
+ const validated = {
79
73
name : 'foo' ,
80
74
version : new SemVer ( '1.2.3' ) ,
81
75
workspaces : [ ] ,
@@ -86,22 +80,19 @@ describe('package-manifest', () => {
86
80
optionalDependencies : { } ,
87
81
peerDependencies : { } ,
88
82
} ;
89
- await fs . promises . writeFile (
90
- manifestPath ,
91
- JSON . stringify ( unvalidatedManifest ) ,
92
- ) ;
83
+ await fs . promises . writeFile ( manifestPath , JSON . stringify ( unvalidated ) ) ;
93
84
94
85
expect ( await readPackageManifest ( manifestPath ) ) . toStrictEqual ( {
95
- unvalidatedManifest ,
96
- validatedManifest ,
86
+ unvalidated ,
87
+ validated ,
97
88
} ) ;
98
89
} ) ;
99
90
} ) ;
100
91
101
92
it ( 'reads a package manifest where optional fields are fully provided' , async ( ) => {
102
93
await withSandbox ( async ( sandbox ) => {
103
94
const manifestPath = path . join ( sandbox . directoryPath , 'package.json' ) ;
104
- const unvalidatedManifest = {
95
+ const unvalidated = {
105
96
name : 'foo' ,
106
97
version : '1.2.3' ,
107
98
workspaces : [ 'packages/*' ] ,
@@ -122,7 +113,7 @@ describe('package-manifest', () => {
122
113
foo : 'bar' ,
123
114
} ,
124
115
} ;
125
- const validatedManifest = {
116
+ const validated = {
126
117
name : 'foo' ,
127
118
version : new SemVer ( '1.2.3' ) ,
128
119
workspaces : [ 'packages/*' ] ,
@@ -143,22 +134,19 @@ describe('package-manifest', () => {
143
134
foo : 'bar' ,
144
135
} ,
145
136
} ;
146
- await fs . promises . writeFile (
147
- manifestPath ,
148
- JSON . stringify ( unvalidatedManifest ) ,
149
- ) ;
137
+ await fs . promises . writeFile ( manifestPath , JSON . stringify ( unvalidated ) ) ;
150
138
151
139
expect ( await readPackageManifest ( manifestPath ) ) . toStrictEqual ( {
152
- unvalidatedManifest ,
153
- validatedManifest ,
140
+ unvalidated ,
141
+ validated ,
154
142
} ) ;
155
143
} ) ;
156
144
} ) ;
157
145
158
146
it ( 'reads a package manifest where dependencies fields are provided but empty' , async ( ) => {
159
147
await withSandbox ( async ( sandbox ) => {
160
148
const manifestPath = path . join ( sandbox . directoryPath , 'package.json' ) ;
161
- const unvalidatedManifest = {
149
+ const unvalidated = {
162
150
name : 'foo' ,
163
151
version : '1.2.3' ,
164
152
private : true ,
@@ -168,7 +156,7 @@ describe('package-manifest', () => {
168
156
optionalDependencies : { } ,
169
157
peerDependencies : { } ,
170
158
} ;
171
- const validatedManifest = {
159
+ const validated = {
172
160
name : 'foo' ,
173
161
version : new SemVer ( '1.2.3' ) ,
174
162
workspaces : [ ] ,
@@ -179,27 +167,24 @@ describe('package-manifest', () => {
179
167
optionalDependencies : { } ,
180
168
peerDependencies : { } ,
181
169
} ;
182
- await fs . promises . writeFile (
183
- manifestPath ,
184
- JSON . stringify ( unvalidatedManifest ) ,
185
- ) ;
170
+ await fs . promises . writeFile ( manifestPath , JSON . stringify ( unvalidated ) ) ;
186
171
187
172
expect ( await readPackageManifest ( manifestPath ) ) . toStrictEqual ( {
188
- unvalidatedManifest ,
189
- validatedManifest ,
173
+ unvalidated ,
174
+ validated ,
190
175
} ) ;
191
176
} ) ;
192
177
} ) ;
193
178
194
179
it ( 'reads a package manifest where the "workspaces" field is provided but empty' , async ( ) => {
195
180
await withSandbox ( async ( sandbox ) => {
196
181
const manifestPath = path . join ( sandbox . directoryPath , 'package.json' ) ;
197
- const unvalidatedManifest = {
182
+ const unvalidated = {
198
183
name : 'foo' ,
199
184
version : '1.2.3' ,
200
185
workspaces : [ ] ,
201
186
} ;
202
- const validatedManifest = {
187
+ const validated = {
203
188
name : 'foo' ,
204
189
version : new SemVer ( '1.2.3' ) ,
205
190
workspaces : [ ] ,
@@ -210,14 +195,11 @@ describe('package-manifest', () => {
210
195
optionalDependencies : { } ,
211
196
peerDependencies : { } ,
212
197
} ;
213
- await fs . promises . writeFile (
214
- manifestPath ,
215
- JSON . stringify ( unvalidatedManifest ) ,
216
- ) ;
198
+ await fs . promises . writeFile ( manifestPath , JSON . stringify ( unvalidated ) ) ;
217
199
218
200
expect ( await readPackageManifest ( manifestPath ) ) . toStrictEqual ( {
219
- unvalidatedManifest ,
220
- validatedManifest ,
201
+ unvalidated ,
202
+ validated ,
221
203
} ) ;
222
204
} ) ;
223
205
} ) ;
0 commit comments