@@ -252,6 +252,47 @@ suite('create-package-json', () => {
252252 } ) ;
253253 } ) ;
254254
255+ suite . only ( 'scaffold workspaces' , ( ) => {
256+ test ( 'workspaces input' , async ( ) => {
257+ await fix . setup ( ) ;
258+ // Empty array is invalid according to npm
259+ const pkg1 = await createPackageJson ( {
260+ workspaces : [ ]
261+ } ) ;
262+ assert . deepStrictEqual ( pkg1 . workspaces , undefined ) ;
263+
264+ await fix . setup ( ) ;
265+ const pkg2 = await createPackageJson ( {
266+ workspaces : [ './lib' ]
267+ } ) ;
268+ assert . deepStrictEqual ( pkg2 . workspaces , [ './lib' ] ) ;
269+
270+ await fix . setup ( ) ;
271+ const pkg3 = await createPackageJson ( {
272+ workspaces : [ './lib/a' , './lib/b' ]
273+ } ) ;
274+ assert . deepStrictEqual ( pkg3 . workspaces , [ './lib/a' , './lib/b' ] ) ;
275+ } ) ;
276+
277+ test ( 'workspaces prompts' , async ( ) => {
278+ await fix . setup ( ) ;
279+ const pkg1 = await createPackageJson ( ) ;
280+ assert . deepStrictEqual ( pkg1 . workspaces , undefined ) ;
281+
282+ const pkg2 = await createPackageJson ( { } , {
283+ promptor : ( ) => {
284+ return async ( prompts ) => {
285+ console . log ( prompts ) ;
286+ return {
287+ workspaces : [ './lib/a' , './lib/b' ]
288+ } ;
289+ } ;
290+ }
291+ } ) ;
292+ assert . deepStrictEqual ( pkg2 . workspaces , [ './lib/a' , './lib/b' ] ) ;
293+ } ) ;
294+ } ) ;
295+
255296 suite ( 'npm init' , ( ) => {
256297 test ( 'parity' , async ( ) => {
257298 await fix . setup ( ) ;
0 commit comments