Skip to content

Commit

Permalink
test: migrate rules tests from ava to jest
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed Jan 19, 2020
1 parent d678d64 commit 94253c6
Show file tree
Hide file tree
Showing 36 changed files with 764 additions and 844 deletions.
22 changes: 0 additions & 22 deletions @commitlint/rules/package.json
Expand Up @@ -11,29 +11,8 @@
"deps": "dep-check",
"pkg": "pkg-check --skip-import",
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
"test": "ava -c 4 --verbose",
"watch": "babel src --out-dir lib --watch --source-maps"
},
"ava": {
"files": [
"src/**/*.test.js",
"!lib/**/*"
],
"source": [
"src/**/*.js",
"!lib/**/*"
],
"babel": {
"testOptions": {
"presets": [
"babel-preset-commitlint"
]
}
},
"require": [
"@babel/register"
]
},
"babel": {
"presets": [
"babel-preset-commitlint"
Expand Down Expand Up @@ -68,7 +47,6 @@
"@commitlint/parse": "^8.3.4",
"@commitlint/test": "8.2.0",
"@commitlint/utils": "^8.3.4",
"ava": "2.4.0",
"babel-preset-commitlint": "^8.2.0",
"concurrently": "3.6.1",
"conventional-changelog-angular": "1.6.6",
Expand Down
49 changes: 24 additions & 25 deletions @commitlint/rules/src/body-case.test.js
@@ -1,4 +1,3 @@
import test from 'ava';
import parse from '@commitlint/parse';
import bodyCase from './body-case';

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

test('with empty body should succeed for "never lowercase"', async t => {
test('with empty body should succeed for "never lowercase"', async () => {
const [actual] = bodyCase(await parsed.empty, 'never', 'lowercase');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with empty body should succeed for "always lowercase"', async t => {
test('with empty body should succeed for "always lowercase"', async () => {
const [actual] = bodyCase(await parsed.empty, 'always', 'lowercase');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with empty body should succeed for "never uppercase"', async t => {
test('with empty body should succeed for "never uppercase"', async () => {
const [actual] = bodyCase(await parsed.empty, 'never', 'uppercase');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with empty body should succeed for "always uppercase"', async t => {
test('with empty body should succeed for "always uppercase"', async () => {
const [actual] = bodyCase(await parsed.empty, 'always', 'uppercase');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with lowercase body should fail for "never lowercase"', async t => {
test('with lowercase body should fail for "never lowercase"', async () => {
const [actual] = bodyCase(await parsed.lowercase, 'never', 'lowercase');
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with lowercase body should succeed for "always lowercase"', async t => {
test('with lowercase body should succeed for "always lowercase"', async () => {
const [actual] = bodyCase(await parsed.lowercase, 'always', 'lowercase');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with mixedcase body should succeed for "never lowercase"', async t => {
test('with mixedcase body should succeed for "never lowercase"', async () => {
const [actual] = bodyCase(await parsed.mixedcase, 'never', 'lowercase');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with mixedcase body should fail for "always lowercase"', async t => {
test('with mixedcase body should fail for "always lowercase"', async () => {
const [actual] = bodyCase(await parsed.mixedcase, 'always', 'lowercase');
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with mixedcase body should succeed for "never uppercase"', async t => {
test('with mixedcase body should succeed for "never uppercase"', async () => {
const [actual] = bodyCase(await parsed.mixedcase, 'never', 'uppercase');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with mixedcase body should fail for "always uppercase"', async t => {
test('with mixedcase body should fail for "always uppercase"', async () => {
const [actual] = bodyCase(await parsed.mixedcase, 'always', 'uppercase');
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with uppercase body should fail for "never uppercase"', async t => {
test('with uppercase body should fail for "never uppercase"', async () => {
const [actual] = bodyCase(await parsed.uppercase, 'never', 'uppercase');
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with lowercase body should succeed for "always uppercase"', async t => {
test('with lowercase body should succeed for "always uppercase"', async () => {
const [actual] = bodyCase(await parsed.uppercase, 'always', 'uppercase');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});
25 changes: 12 additions & 13 deletions @commitlint/rules/src/body-empty.test.js
@@ -1,4 +1,3 @@
import test from 'ava';
import parse from '@commitlint/parse';
import bodyEmpty from './body-empty';

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

test('with empty body should succeed for empty keyword', async t => {
test('with empty body should succeed for empty keyword', async () => {
const [actual] = bodyEmpty(await parsed.empty);
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with empty body should fail for "never"', async t => {
test('with empty body should fail for "never"', async () => {
const [actual] = bodyEmpty(await parsed.empty, 'never');
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with empty body should succeed for "always"', async t => {
test('with empty body should succeed for "always"', async () => {
const [actual] = bodyEmpty(await parsed.empty, 'always');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with body should fail for empty keyword', async t => {
test('with body should fail for empty keyword', async () => {
const [actual] = bodyEmpty(await parsed.filled);
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with body should succeed for "never"', async t => {
test('with body should succeed for "never"', async () => {
const [actual] = bodyEmpty(await parsed.filled, 'never');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with body should fail for "always"', async t => {
test('with body should fail for "always"', async () => {
const [actual] = bodyEmpty(await parsed.filled, 'always');
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});
37 changes: 18 additions & 19 deletions @commitlint/rules/src/body-leading-blank.test.js
@@ -1,4 +1,3 @@
import test from 'ava';
import parse from '@commitlint/parse';
import bodyLeadingBlank from './body-leading-blank';

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

test('with simple message should succeed for empty keyword', async t => {
test('with simple message should succeed for empty keyword', async () => {
const [actual] = bodyLeadingBlank(await parsed.simple);
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with simple message should succeed for "never"', async t => {
test('with simple message should succeed for "never"', async () => {
const [actual] = bodyLeadingBlank(await parsed.simple, 'never');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with simple message should succeed for "always"', async t => {
test('with simple message should succeed for "always"', async () => {
const [actual] = bodyLeadingBlank(await parsed.simple, 'always');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('without blank line before body should fail for empty keyword', async t => {
test('without blank line before body should fail for empty keyword', async () => {
const [actual] = bodyLeadingBlank(await parsed.without);
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('without blank line before body should succeed for "never"', async t => {
test('without blank line before body should succeed for "never"', async () => {
const [actual] = bodyLeadingBlank(await parsed.without, 'never');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('without blank line before body should fail for "always"', async t => {
test('without blank line before body should fail for "always"', async () => {
const [actual] = bodyLeadingBlank(await parsed.without, 'always');
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with blank line before body should succeed for empty keyword', async t => {
test('with blank line before body should succeed for empty keyword', async () => {
const [actual] = bodyLeadingBlank(await parsed.with);
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with blank line before body should fail for "never"', async t => {
test('with blank line before body should fail for "never"', async () => {
const [actual] = bodyLeadingBlank(await parsed.with, 'never');
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with blank line before body should succeed for "always"', async t => {
test('with blank line before body should succeed for "always"', async () => {
const [actual] = bodyLeadingBlank(await parsed.with, 'always');
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});
13 changes: 6 additions & 7 deletions @commitlint/rules/src/body-max-length.test.js
@@ -1,4 +1,3 @@
import test from 'ava';
import parse from '@commitlint/parse';
import check from './body-max-length';

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

test('with empty should succeed', async t => {
test('with empty should succeed', async () => {
const [actual] = check(await parsed.empty, '', value);
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with short should succeed', async t => {
test('with short should succeed', async () => {
const [actual] = check(await parsed.short, '', value);
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with long should fail', async t => {
test('with long should fail', async () => {
const [actual] = check(await parsed.long, '', value);
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});
21 changes: 10 additions & 11 deletions @commitlint/rules/src/body-max-line-length.test.js
@@ -1,4 +1,3 @@
import test from 'ava';
import parse from '@commitlint/parse';
import check from './body-max-line-length';

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

test('with empty should succeed', async t => {
test('with empty should succeed', async () => {
const [actual] = check(await parsed.empty, '', value);
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with short should succeed', async t => {
test('with short should succeed', async () => {
const [actual] = check(await parsed.short, '', value);
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with long should fail', async t => {
test('with long should fail', async () => {
const [actual] = check(await parsed.long, '', value);
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with short with multiple lines should succeed', async t => {
test('with short with multiple lines should succeed', async () => {
const [actual] = check(await parsed.short, '', value);
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with long with multiple lines should fail', async t => {
test('with long with multiple lines should fail', async () => {
const [actual] = check(await parsed.long, '', value);
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});
13 changes: 6 additions & 7 deletions @commitlint/rules/src/body-min-length.test.js
@@ -1,4 +1,3 @@
import test from 'ava';
import parse from '@commitlint/parse';
import check from './body-min-length';

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

test('with simple should succeed', async t => {
test('with simple should succeed', async () => {
const [actual] = check(await parsed.simple, '', value);
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with short should fail', async t => {
test('with short should fail', async () => {
const [actual] = check(await parsed.short, '', value);
const expected = false;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

test('with long should succeed', async t => {
test('with long should succeed', async () => {
const [actual] = check(await parsed.long, '', value);
const expected = true;
t.is(actual, expected);
expect(actual).toEqual(expected);
});

0 comments on commit 94253c6

Please sign in to comment.