forked from conventional-changelog/commitlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.ts
53 lines (41 loc) · 1.69 KB
/
index.test.ts
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
import execa from 'execa';
const {git} = require('@commitlint/test');
const sander = require('@marionebl/sander');
import read from '.';
test('get edit commit message specified by the `edit` flag', async () => {
const cwd: string = await git.bootstrap();
await sander.writeFile(cwd, 'commit-msg-file', 'foo');
const expected = ['foo\n'];
const actual = await read({edit: 'commit-msg-file', cwd});
expect(actual).toEqual(expected);
});
test('get edit commit message from git root', async () => {
const cwd: string = await git.bootstrap();
await sander.writeFile(cwd, 'alpha.txt', 'alpha');
await execa('git', ['add', '.'], {cwd});
await execa('git', ['commit', '-m', 'alpha'], {cwd});
const expected = ['alpha\n\n'];
const actual = await read({edit: true, cwd});
expect(actual).toEqual(expected);
});
test('get history commit messages', async () => {
const cwd: string = await git.bootstrap();
await sander.writeFile(cwd, 'alpha.txt', 'alpha');
await execa('git', ['add', 'alpha.txt'], {cwd});
await execa('git', ['commit', '-m', 'alpha'], {cwd});
await execa('git', ['rm', 'alpha.txt'], {cwd});
await execa('git', ['commit', '-m', 'remove alpha'], {cwd});
const expected = ['remove alpha\n\n', 'alpha\n\n'];
const actual = await read({cwd});
expect(actual).toEqual(expected);
});
test('get edit commit message from git subdirectory', async () => {
const cwd: string = await git.bootstrap();
await sander.mkdir(cwd, 'beta');
await sander.writeFile(cwd, 'beta/beta.txt', 'beta');
await execa('git', ['add', '.'], {cwd});
await execa('git', ['commit', '-m', 'beta'], {cwd});
const expected = ['beta\n\n'];
const actual = await read({edit: true, cwd});
expect(actual).toEqual(expected);
});