forked from conventional-changelog/commitlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
60 lines (50 loc) · 1.47 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import {npm} from '@commitlint/test';
import config from '.';
test('exports rules key', () => {
expect(config).toHaveProperty('rules');
});
test('rules hold object', () => {
expect(config).toMatchObject({
rules: expect.any(Object),
});
});
test('rules contain scope-enum', () => {
expect(config).toMatchObject({
rules: {
'scope-enum': expect.anything(),
},
});
});
test('scope-enum is function', () => {
expect(config).toMatchObject({
rules: {
'scope-enum': expect.any(Function),
},
});
});
test('scope-enum does not throw for missing context', async () => {
const {'scope-enum': fn} = config.rules;
await expect(fn()).resolves.toBeTruthy();
});
test('scope-enum has expected severity', async () => {
const {'scope-enum': fn} = config.rules;
const [severity] = await fn();
expect(severity).toBe(2);
});
test('scope-enum has expected modifier', async () => {
const {'scope-enum': fn} = config.rules;
const [, modifier] = await fn();
expect(modifier).toBe('always');
});
test('returns empty value for empty nx repository', async () => {
const {'scope-enum': fn} = config.rules;
const cwd = await npm.bootstrap('fixtures/empty', __dirname);
const [, , value] = await fn({cwd});
expect(value).toEqual([]);
});
test('returns expected value for basic nx repository', async () => {
const {'scope-enum': fn} = config.rules;
const cwd = await npm.bootstrap('fixtures/basic', __dirname);
const [, , value] = await fn({cwd});
expect(value).toEqual(['a', 'b']);
});