Skip to content

Commit a474224

Browse files
authored
test(prompt): migrate ava tests to jest (#916)
1 parent ff11998 commit a474224

File tree

3 files changed

+15
-39
lines changed

3 files changed

+15
-39
lines changed

@commitlint/prompt/package.json

+1-23
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,9 @@
1111
"commit": "git-cz",
1212
"deps": "dep-check",
1313
"pkg": "pkg-check --skip-import",
14-
"start": "concurrently \"ava --watch --verbose\" \"yarn run watch\"",
15-
"test": "ava --verbose",
14+
"start": "yarn run watch",
1615
"watch": "babel src --out-dir lib --watch --source-maps"
1716
},
18-
"ava": {
19-
"babel": {
20-
"testOptions": {
21-
"presets": [
22-
"babel-preset-commitlint"
23-
]
24-
}
25-
},
26-
"require": [
27-
"@babel/register"
28-
],
29-
"files": [
30-
"src/**/*.test.js"
31-
],
32-
"sources": [
33-
"src/**/*.js"
34-
]
35-
},
3617
"babel": {
3718
"presets": [
3819
"commitlint"
@@ -63,12 +44,9 @@
6344
"devDependencies": {
6445
"@babel/cli": "^7.7.7",
6546
"@babel/core": "^7.7.7",
66-
"@babel/register": "^7.7.7",
6747
"@commitlint/utils": "^8.3.4",
68-
"ava": "2.4.0",
6948
"babel-preset-commitlint": "^8.2.0",
7049
"commitizen": "3.1.2",
71-
"concurrently": "3.6.1",
7250
"cross-env": "6.0.3"
7351
},
7452
"dependencies": {

@commitlint/prompt/src/library/get-prompt.test.js

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
1-
import test from 'ava';
21
import getPrompt from './get-prompt';
32

4-
test('throws without params', t => {
5-
t.throws(() => getPrompt(), /Missing prompter function/);
3+
test('throws without params', () => {
4+
expect(() => getPrompt()).toThrow('Missing prompter function');
65
});
76

8-
test('throws with incompatible prompter', t => {
9-
t.throws(
10-
() =>
11-
getPrompt('type', {
12-
prompter() {
13-
return {};
14-
}
15-
}),
16-
/prompt.removeAllListeners/
17-
);
7+
test('throws with incompatible prompter', () => {
8+
expect(() =>
9+
getPrompt('type', {
10+
prompter() {
11+
return {};
12+
}
13+
})
14+
).toThrow('prompt.removeAllListeners');
1815
});
1916

20-
test('returns input unaltered wihtout rules', async t => {
17+
test('returns input unaltered wihtout rules', async () => {
2118
const message = await getPrompt('type', {
2219
prompter: stub('foobar')
2320
});
2421

25-
t.is(message, 'foobar');
22+
expect(message).toEqual('foobar');
2623
});
2724

2825
function stub(input = '') {

jest.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
'**/@commitlint/read/src/*.test.js?(x)',
99
'**/@commitlint/travis-cli/src/*.test.js?(x)',
1010
'**/@commitlint/cli/src/*.test.js?(x)',
11-
'**/@commitlint/prompt-cli/*.test.js?(x)'
11+
'**/@commitlint/prompt-cli/*.test.js?(x)',
12+
'**/@commitlint/prompt/src/**/*.test.js?(x)'
1213
]
1314
};

0 commit comments

Comments
 (0)