@@ -4,12 +4,13 @@ import * as td from 'testdouble';
44import any from '@travi/any' ;
55
66suite ( 'mocha remover' , ( ) => {
7- let remove , canaryExists , removeCanary , configExists , removeConfig ;
7+ let remove , canaryExists , removeCanary , configExists , removeConfig , setupExists , removeSetup ;
88 const projectRoot = any . string ( ) ;
99
1010 setup ( async ( ) => {
1111 ( { remove : removeCanary , test : canaryExists } = await td . replaceEsm ( './canary/index.js' ) ) ;
1212 ( { remove : removeConfig , test : configExists } = await td . replaceEsm ( './configuration/index.js' ) ) ;
13+ ( { remove : removeSetup , test : setupExists } = await td . replaceEsm ( './setup/index.js' ) ) ;
1314
1415 ( { default : remove } = ( await import ( './remover.js' ) ) ) ;
1516 } ) ;
@@ -19,11 +20,13 @@ suite('mocha remover', () => {
1920 test ( 'that mocha details are removed from the project' , async ( ) => {
2021 td . when ( canaryExists ( { projectRoot} ) ) . thenResolve ( true ) ;
2122 td . when ( configExists ( { projectRoot} ) ) . thenResolve ( true ) ;
23+ td . when ( setupExists ( { projectRoot} ) ) . thenResolve ( true ) ;
2224
2325 const { dependencies} = await remove ( { projectRoot} ) ;
2426
2527 td . verify ( removeCanary ( { projectRoot} ) ) ;
2628 td . verify ( removeConfig ( { projectRoot} ) ) ;
29+ td . verify ( removeSetup ( { projectRoot} ) ) ;
2730 assert . deepEqual ( dependencies . javascript . remove , [ 'mocha' , 'chai' , 'sinon' ] ) ;
2831 } ) ;
2932
@@ -42,4 +45,12 @@ suite('mocha remover', () => {
4245
4346 td . verify ( removeConfig ( { projectRoot} ) , { times : 0 } ) ;
4447 } ) ;
48+
49+ test ( 'that removing the setup file is not attempted if it does not exist' , async ( ) => {
50+ td . when ( setupExists ( { projectRoot} ) ) . thenResolve ( false ) ;
51+
52+ await remove ( { projectRoot} ) ;
53+
54+ td . verify ( removeSetup ( { projectRoot} ) , { times : 0 } ) ;
55+ } ) ;
4556} ) ;
0 commit comments