Skip to content

Commit b111e8f

Browse files
armano2byCedric
authored andcommitted
test(rules): migrate rules tests from ava to jest (#900)
1 parent 2549f79 commit b111e8f

37 files changed

+768
-844
lines changed

@commitlint/rules/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"
@@ -68,7 +47,6 @@
6847
"@commitlint/parse": "^8.3.4",
6948
"@commitlint/test": "8.2.0",
7049
"@commitlint/utils": "^8.3.4",
71-
"ava": "2.4.0",
7250
"babel-preset-commitlint": "^8.2.0",
7351
"concurrently": "3.6.1",
7452
"conventional-changelog-angular": "1.6.6",
+24-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import test from 'ava';
21
import parse from '@commitlint/parse';
32
import bodyCase from './body-case';
43

@@ -16,74 +15,74 @@ const parsed = {
1615
uppercase: parse(messages.uppercase)
1716
};
1817

19-
test('with empty body should succeed for "never lowercase"', async t => {
18+
test('with empty body should succeed for "never lowercase"', async () => {
2019
const [actual] = bodyCase(await parsed.empty, 'never', 'lowercase');
2120
const expected = true;
22-
t.is(actual, expected);
21+
expect(actual).toEqual(expected);
2322
});
2423

25-
test('with empty body should succeed for "always lowercase"', async t => {
24+
test('with empty body should succeed for "always lowercase"', async () => {
2625
const [actual] = bodyCase(await parsed.empty, 'always', 'lowercase');
2726
const expected = true;
28-
t.is(actual, expected);
27+
expect(actual).toEqual(expected);
2928
});
3029

31-
test('with empty body should succeed for "never uppercase"', async t => {
30+
test('with empty body should succeed for "never uppercase"', async () => {
3231
const [actual] = bodyCase(await parsed.empty, 'never', 'uppercase');
3332
const expected = true;
34-
t.is(actual, expected);
33+
expect(actual).toEqual(expected);
3534
});
3635

37-
test('with empty body should succeed for "always uppercase"', async t => {
36+
test('with empty body should succeed for "always uppercase"', async () => {
3837
const [actual] = bodyCase(await parsed.empty, 'always', 'uppercase');
3938
const expected = true;
40-
t.is(actual, expected);
39+
expect(actual).toEqual(expected);
4140
});
4241

43-
test('with lowercase body should fail for "never lowercase"', async t => {
42+
test('with lowercase body should fail for "never lowercase"', async () => {
4443
const [actual] = bodyCase(await parsed.lowercase, 'never', 'lowercase');
4544
const expected = false;
46-
t.is(actual, expected);
45+
expect(actual).toEqual(expected);
4746
});
4847

49-
test('with lowercase body should succeed for "always lowercase"', async t => {
48+
test('with lowercase body should succeed for "always lowercase"', async () => {
5049
const [actual] = bodyCase(await parsed.lowercase, 'always', 'lowercase');
5150
const expected = true;
52-
t.is(actual, expected);
51+
expect(actual).toEqual(expected);
5352
});
5453

55-
test('with mixedcase body should succeed for "never lowercase"', async t => {
54+
test('with mixedcase body should succeed for "never lowercase"', async () => {
5655
const [actual] = bodyCase(await parsed.mixedcase, 'never', 'lowercase');
5756
const expected = true;
58-
t.is(actual, expected);
57+
expect(actual).toEqual(expected);
5958
});
6059

61-
test('with mixedcase body should fail for "always lowercase"', async t => {
60+
test('with mixedcase body should fail for "always lowercase"', async () => {
6261
const [actual] = bodyCase(await parsed.mixedcase, 'always', 'lowercase');
6362
const expected = false;
64-
t.is(actual, expected);
63+
expect(actual).toEqual(expected);
6564
});
6665

67-
test('with mixedcase body should succeed for "never uppercase"', async t => {
66+
test('with mixedcase body should succeed for "never uppercase"', async () => {
6867
const [actual] = bodyCase(await parsed.mixedcase, 'never', 'uppercase');
6968
const expected = true;
70-
t.is(actual, expected);
69+
expect(actual).toEqual(expected);
7170
});
7271

73-
test('with mixedcase body should fail for "always uppercase"', async t => {
72+
test('with mixedcase body should fail for "always uppercase"', async () => {
7473
const [actual] = bodyCase(await parsed.mixedcase, 'always', 'uppercase');
7574
const expected = false;
76-
t.is(actual, expected);
75+
expect(actual).toEqual(expected);
7776
});
7877

79-
test('with uppercase body should fail for "never uppercase"', async t => {
78+
test('with uppercase body should fail for "never uppercase"', async () => {
8079
const [actual] = bodyCase(await parsed.uppercase, 'never', 'uppercase');
8180
const expected = false;
82-
t.is(actual, expected);
81+
expect(actual).toEqual(expected);
8382
});
8483

85-
test('with lowercase body should succeed for "always uppercase"', async t => {
84+
test('with lowercase body should succeed for "always uppercase"', async () => {
8685
const [actual] = bodyCase(await parsed.uppercase, 'always', 'uppercase');
8786
const expected = true;
88-
t.is(actual, expected);
87+
expect(actual).toEqual(expected);
8988
});
+12-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import test from 'ava';
21
import parse from '@commitlint/parse';
32
import bodyEmpty from './body-empty';
43

@@ -12,38 +11,38 @@ const parsed = {
1211
filled: parse(messages.filled)
1312
};
1413

15-
test('with empty body should succeed for empty keyword', async t => {
14+
test('with empty body should succeed for empty keyword', async () => {
1615
const [actual] = bodyEmpty(await parsed.empty);
1716
const expected = true;
18-
t.is(actual, expected);
17+
expect(actual).toEqual(expected);
1918
});
2019

21-
test('with empty body should fail for "never"', async t => {
20+
test('with empty body should fail for "never"', async () => {
2221
const [actual] = bodyEmpty(await parsed.empty, 'never');
2322
const expected = false;
24-
t.is(actual, expected);
23+
expect(actual).toEqual(expected);
2524
});
2625

27-
test('with empty body should succeed for "always"', async t => {
26+
test('with empty body should succeed for "always"', async () => {
2827
const [actual] = bodyEmpty(await parsed.empty, 'always');
2928
const expected = true;
30-
t.is(actual, expected);
29+
expect(actual).toEqual(expected);
3130
});
3231

33-
test('with body should fail for empty keyword', async t => {
32+
test('with body should fail for empty keyword', async () => {
3433
const [actual] = bodyEmpty(await parsed.filled);
3534
const expected = false;
36-
t.is(actual, expected);
35+
expect(actual).toEqual(expected);
3736
});
3837

39-
test('with body should succeed for "never"', async t => {
38+
test('with body should succeed for "never"', async () => {
4039
const [actual] = bodyEmpty(await parsed.filled, 'never');
4140
const expected = true;
42-
t.is(actual, expected);
41+
expect(actual).toEqual(expected);
4342
});
4443

45-
test('with body should fail for "always"', async t => {
44+
test('with body should fail for "always"', async () => {
4645
const [actual] = bodyEmpty(await parsed.filled, 'always');
4746
const expected = false;
48-
t.is(actual, expected);
47+
expect(actual).toEqual(expected);
4948
});
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import test from 'ava';
21
import parse from '@commitlint/parse';
32
import bodyLeadingBlank from './body-leading-blank';
43

@@ -14,56 +13,56 @@ const parsed = {
1413
with: parse(messages.with)
1514
};
1615

17-
test('with simple message should succeed for empty keyword', async t => {
16+
test('with simple message should succeed for empty keyword', async () => {
1817
const [actual] = bodyLeadingBlank(await parsed.simple);
1918
const expected = true;
20-
t.is(actual, expected);
19+
expect(actual).toEqual(expected);
2120
});
2221

23-
test('with simple message should succeed for "never"', async t => {
22+
test('with simple message should succeed for "never"', async () => {
2423
const [actual] = bodyLeadingBlank(await parsed.simple, 'never');
2524
const expected = true;
26-
t.is(actual, expected);
25+
expect(actual).toEqual(expected);
2726
});
2827

29-
test('with simple message should succeed for "always"', async t => {
28+
test('with simple message should succeed for "always"', async () => {
3029
const [actual] = bodyLeadingBlank(await parsed.simple, 'always');
3130
const expected = true;
32-
t.is(actual, expected);
31+
expect(actual).toEqual(expected);
3332
});
3433

35-
test('without blank line before body should fail for empty keyword', async t => {
34+
test('without blank line before body should fail for empty keyword', async () => {
3635
const [actual] = bodyLeadingBlank(await parsed.without);
3736
const expected = false;
38-
t.is(actual, expected);
37+
expect(actual).toEqual(expected);
3938
});
4039

41-
test('without blank line before body should succeed for "never"', async t => {
40+
test('without blank line before body should succeed for "never"', async () => {
4241
const [actual] = bodyLeadingBlank(await parsed.without, 'never');
4342
const expected = true;
44-
t.is(actual, expected);
43+
expect(actual).toEqual(expected);
4544
});
4645

47-
test('without blank line before body should fail for "always"', async t => {
46+
test('without blank line before body should fail for "always"', async () => {
4847
const [actual] = bodyLeadingBlank(await parsed.without, 'always');
4948
const expected = false;
50-
t.is(actual, expected);
49+
expect(actual).toEqual(expected);
5150
});
5251

53-
test('with blank line before body should succeed for empty keyword', async t => {
52+
test('with blank line before body should succeed for empty keyword', async () => {
5453
const [actual] = bodyLeadingBlank(await parsed.with);
5554
const expected = true;
56-
t.is(actual, expected);
55+
expect(actual).toEqual(expected);
5756
});
5857

59-
test('with blank line before body should fail for "never"', async t => {
58+
test('with blank line before body should fail for "never"', async () => {
6059
const [actual] = bodyLeadingBlank(await parsed.with, 'never');
6160
const expected = false;
62-
t.is(actual, expected);
61+
expect(actual).toEqual(expected);
6362
});
6463

65-
test('with blank line before body should succeed for "always"', async t => {
64+
test('with blank line before body should succeed for "always"', async () => {
6665
const [actual] = bodyLeadingBlank(await parsed.with, 'always');
6766
const expected = true;
68-
t.is(actual, expected);
67+
expect(actual).toEqual(expected);
6968
});

@commitlint/rules/src/body-max-length.test.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import test from 'ava';
21
import parse from '@commitlint/parse';
32
import check from './body-max-length';
43

@@ -19,20 +18,20 @@ const parsed = {
1918
long: parse(messages.long)
2019
};
2120

22-
test('with empty should succeed', async t => {
21+
test('with empty should succeed', async () => {
2322
const [actual] = check(await parsed.empty, '', value);
2423
const expected = true;
25-
t.is(actual, expected);
24+
expect(actual).toEqual(expected);
2625
});
2726

28-
test('with short should succeed', async t => {
27+
test('with short should succeed', async () => {
2928
const [actual] = check(await parsed.short, '', value);
3029
const expected = true;
31-
t.is(actual, expected);
30+
expect(actual).toEqual(expected);
3231
});
3332

34-
test('with long should fail', async t => {
33+
test('with long should fail', async () => {
3534
const [actual] = check(await parsed.long, '', value);
3635
const expected = false;
37-
t.is(actual, expected);
36+
expect(actual).toEqual(expected);
3837
});

@commitlint/rules/src/body-max-line-length.test.js

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import test from 'ava';
21
import parse from '@commitlint/parse';
32
import check from './body-max-line-length';
43

@@ -21,32 +20,32 @@ const parsed = {
2120
long: parse(messages.long)
2221
};
2322

24-
test('with empty should succeed', async t => {
23+
test('with empty should succeed', async () => {
2524
const [actual] = check(await parsed.empty, '', value);
2625
const expected = true;
27-
t.is(actual, expected);
26+
expect(actual).toEqual(expected);
2827
});
2928

30-
test('with short should succeed', async t => {
29+
test('with short should succeed', async () => {
3130
const [actual] = check(await parsed.short, '', value);
3231
const expected = true;
33-
t.is(actual, expected);
32+
expect(actual).toEqual(expected);
3433
});
3534

36-
test('with long should fail', async t => {
35+
test('with long should fail', async () => {
3736
const [actual] = check(await parsed.long, '', value);
3837
const expected = false;
39-
t.is(actual, expected);
38+
expect(actual).toEqual(expected);
4039
});
4140

42-
test('with short with multiple lines should succeed', async t => {
41+
test('with short with multiple lines should succeed', async () => {
4342
const [actual] = check(await parsed.short, '', value);
4443
const expected = true;
45-
t.is(actual, expected);
44+
expect(actual).toEqual(expected);
4645
});
4746

48-
test('with long with multiple lines should fail', async t => {
47+
test('with long with multiple lines should fail', async () => {
4948
const [actual] = check(await parsed.long, '', value);
5049
const expected = false;
51-
t.is(actual, expected);
50+
expect(actual).toEqual(expected);
5251
});

@commitlint/rules/src/body-min-length.test.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import test from 'ava';
21
import parse from '@commitlint/parse';
32
import check from './body-min-length';
43

@@ -19,20 +18,20 @@ const parsed = {
1918
long: parse(messages.long)
2019
};
2120

22-
test('with simple should succeed', async t => {
21+
test('with simple should succeed', async () => {
2322
const [actual] = check(await parsed.simple, '', value);
2423
const expected = true;
25-
t.is(actual, expected);
24+
expect(actual).toEqual(expected);
2625
});
2726

28-
test('with short should fail', async t => {
27+
test('with short should fail', async () => {
2928
const [actual] = check(await parsed.short, '', value);
3029
const expected = false;
31-
t.is(actual, expected);
30+
expect(actual).toEqual(expected);
3231
});
3332

34-
test('with long should succeed', async t => {
33+
test('with long should succeed', async () => {
3534
const [actual] = check(await parsed.long, '', value);
3635
const expected = true;
37-
t.is(actual, expected);
36+
expect(actual).toEqual(expected);
3837
});

0 commit comments

Comments
 (0)