Skip to content

Commit 55b35bc

Browse files
committed
feat(predicate): define a predicate for determining if mocha exists in a project
1 parent 5e5e0b2 commit 55b35bc

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export {default as scaffold} from './scaffolder.js';
2+
export {default as test} from './tester.js';
23
export {default as remove} from './remover.js';

src/tester-test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {assert} from 'chai';
2+
3+
import any from '@travi/any';
4+
import * as td from 'testdouble';
5+
6+
suite('mocha predicate', () => {
7+
let checkForMocha, core;
8+
const projectRoot = any.string();
9+
10+
setup(async () => {
11+
core = await td.replaceEsm('@form8ion/core');
12+
13+
({default: checkForMocha} = (await import('./tester.js')));
14+
});
15+
16+
teardown(() => td.reset());
17+
18+
test('that `false` is returned if no evidence of mocha is detected', async () => {
19+
td.when(core.fileExists(`${projectRoot}/.mocharc.json`)).thenResolve(false);
20+
21+
assert.isFalse(await checkForMocha({projectRoot}));
22+
});
23+
24+
test('that `true` is returned if the `.mocharc.json` file is found in the project', async () => {
25+
td.when(core.fileExists(`${projectRoot}/.mocharc.json`)).thenResolve(true);
26+
27+
assert.isTrue(await checkForMocha({projectRoot}));
28+
});
29+
});

src/tester.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {fileExists} from '@form8ion/core';
2+
3+
export default function ({projectRoot}) {
4+
return fileExists(`${projectRoot}/.mocharc.json`);
5+
}

0 commit comments

Comments
 (0)