Skip to content

Commit cddbf09

Browse files
committed
test(rules): migrate read tests from ava to jest
1 parent 10556ec commit cddbf09

File tree

3 files changed

+13
-32
lines changed

3 files changed

+13
-32
lines changed

@commitlint/read/package.json

-22
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,8 @@
1111
"deps": "dep-check",
1212
"pkg": "pkg-check --skip-import",
1313
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
14-
"test": "ava -c 4 --verbose",
1514
"watch": "babel src --out-dir lib --watch --source-maps"
1615
},
17-
"ava": {
18-
"files": [
19-
"src/**/*.test.js",
20-
"!lib/**/*"
21-
],
22-
"source": [
23-
"src/**/*.js",
24-
"!lib/**/*"
25-
],
26-
"babel": {
27-
"testOptions": {
28-
"presets": [
29-
"babel-preset-commitlint"
30-
]
31-
}
32-
},
33-
"require": [
34-
"@babel/register"
35-
]
36-
},
3716
"babel": {
3817
"presets": [
3918
"babel-preset-commitlint"
@@ -67,7 +46,6 @@
6746
"@babel/register": "7.7.7",
6847
"@commitlint/test": "8.2.0",
6948
"@commitlint/utils": "^8.3.4",
70-
"ava": "2.4.0",
7149
"babel-preset-commitlint": "^8.2.0",
7250
"concurrently": "3.6.1",
7351
"cross-env": "6.0.3",

@commitlint/read/src/index.test.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
import {git} from '@commitlint/test';
2-
import test from 'ava';
32
import execa from 'execa';
43
import * as sander from '@marionebl/sander';
54

65
import read from '.';
76

8-
test('get edit commit message specified by the `edit` flag', async t => {
7+
test('get edit commit message specified by the `edit` flag', async () => {
98
const cwd = await git.bootstrap();
109

1110
await sander.writeFile(cwd, 'commit-msg-file', 'foo');
1211

1312
const expected = ['foo\n'];
1413
const actual = await read({edit: 'commit-msg-file', cwd});
15-
t.deepEqual(actual, expected);
14+
expect(actual).toEqual(expected);
1615
});
1716

18-
test('get edit commit message from git root', async t => {
17+
test('get edit commit message from git root', async () => {
1918
const cwd = await git.bootstrap();
2019

2120
await sander.writeFile(cwd, 'alpha.txt', 'alpha');
2221
await execa('git', ['add', '.'], {cwd});
2322
await execa('git', ['commit', '-m', 'alpha'], {cwd});
2423
const expected = ['alpha\n\n'];
2524
const actual = await read({edit: true, cwd});
26-
t.deepEqual(actual, expected);
25+
expect(actual).toEqual(expected);
2726
});
2827

29-
test('get history commit messages', async t => {
28+
test('get history commit messages', async () => {
3029
const cwd = await git.bootstrap();
3130
await sander.writeFile(cwd, 'alpha.txt', 'alpha');
3231
await execa('git', ['add', 'alpha.txt'], {cwd});
@@ -36,10 +35,10 @@ test('get history commit messages', async t => {
3635

3736
const expected = ['remove alpha\n\n', 'alpha\n\n'];
3837
const actual = await read({cwd});
39-
t.deepEqual(actual, expected);
38+
expect(actual).toEqual(expected);
4039
});
4140

42-
test('get edit commit message from git subdirectory', async t => {
41+
test('get edit commit message from git subdirectory', async () => {
4342
const cwd = await git.bootstrap();
4443
await sander.mkdir(cwd, 'beta');
4544
await sander.writeFile(cwd, 'beta/beta.txt', 'beta');
@@ -49,5 +48,5 @@ test('get edit commit message from git subdirectory', async t => {
4948

5049
const expected = ['beta\n\n'];
5150
const actual = await read({edit: true, cwd});
52-
t.deepEqual(actual, expected);
51+
expect(actual).toEqual(expected);
5352
});

jest.config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@ module.exports = {
22
preset: 'ts-jest/presets/js-with-babel',
33
testEnvironment: 'node',
44
testRegex: undefined,
5-
testMatch: ['**/*.test.ts?(x)', '**/@commitlint/rules/src/*.test.js?(x)']
5+
testMatch: [
6+
'**/*.test.ts?(x)',
7+
'**/@commitlint/rules/src/*.test.js?(x)',
8+
'**/@commitlint/read/src/*.test.js?(x)'
9+
]
610
};

0 commit comments

Comments
 (0)