-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(remove): remove the
.mocharc.json
file when removing mocha fro…
…m a project
- Loading branch information
Showing
9 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export {default as remove} from './remover.js'; | ||
export {default as test} from './tester.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as td from 'testdouble'; | ||
import any from '@travi/any'; | ||
|
||
suite('mocha config remover', () => { | ||
let remove, fs; | ||
|
||
setup(async () => { | ||
fs = await td.replaceEsm('node:fs'); | ||
|
||
({default: remove} = (await import('./remover.js'))); | ||
}); | ||
|
||
teardown(() => td.reset()); | ||
|
||
test('that the config file is removed', async () => { | ||
const projectRoot = any.simpleObject(); | ||
|
||
await remove({projectRoot}); | ||
|
||
td.verify(fs.promises.unlink(`${projectRoot}/.mocharc.json`)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {promises as fs} from 'fs'; | ||
|
||
export default async function ({projectRoot}) { | ||
await fs.unlink(`${projectRoot}/.mocharc.json`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as td from 'testdouble'; | ||
import {assert} from 'chai'; | ||
import any from '@travi/any'; | ||
|
||
suite('configuration predicate', () => { | ||
let canaryExists, core; | ||
const projectRoot = any.string(); | ||
|
||
setup(async () => { | ||
core = await td.replaceEsm('@form8ion/core'); | ||
|
||
({default: canaryExists} = (await import('./tester.js'))); | ||
}); | ||
|
||
teardown(() => td.reset()); | ||
|
||
test('that `false` is returned if the canary test does not exist', async () => { | ||
td.when(core.fileExists(`${projectRoot}/.mocharc.json`)).thenResolve(false); | ||
|
||
assert.isFalse(await canaryExists({projectRoot})); | ||
}); | ||
|
||
test('that `true` is returned if the canary test does not exist', async () => { | ||
td.when(core.fileExists(`${projectRoot}/.mocharc.json`)).thenResolve(true); | ||
|
||
assert.isTrue(await canaryExists({projectRoot})); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {fileExists} from '@form8ion/core'; | ||
|
||
export default function ({projectRoot}) { | ||
return fileExists(`${projectRoot}/.mocharc.json`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import {test as canaryExists, remove as removeCanary} from './canary/index.js'; | ||
import {test as configExists, remove as removeConfig} from './configuration/index.js'; | ||
|
||
export default async function ({projectRoot}) { | ||
if (await canaryExists({projectRoot})) { | ||
await removeCanary({projectRoot}); | ||
} | ||
|
||
if (await configExists({projectRoot})) { | ||
await removeConfig({projectRoot}); | ||
} | ||
|
||
return {dependencies: {javascript: {remove: ['mocha', 'chai', 'sinon']}}}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters