-
-
Notifications
You must be signed in to change notification settings - Fork 313
/
log-name-status.spec.ts
50 lines (44 loc) · 1.34 KB
/
log-name-status.spec.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
import {
createTestContext,
like,
newSimpleGit,
setUpFilesAdded,
setUpInit,
SimpleGitTestContext,
} from '@simple-git/test-utils';
import { DiffNameStatus, DiffResultTextFile } from '../..';
describe('log-name-status', function () {
let context: SimpleGitTestContext;
const steps = ['mv a b', 'commit -m two'];
beforeEach(async () => {
context = await createTestContext();
await setUpInit(context);
await setUpFilesAdded(context, ['a'], '.', 'one');
for (const step of steps) {
await context.git.raw(step.split(' '));
}
});
it('detects files moved with --name-status', async () => {
const actual = await newSimpleGit(context.root).log(['--name-status']);
expect(actual.all).toEqual([
mockListLogLine('two', { b: DiffNameStatus.RENAMED }),
mockListLogLine('one', { a: DiffNameStatus.ADDED }),
]);
});
});
function mockListLogLine(message: string, changes: Record<string, DiffNameStatus>) {
const files: DiffResultTextFile[] = Object.entries(changes).map(([file, status]) => {
return {
binary: false,
changes: 0,
deletions: 0,
file,
insertions: 0,
status,
};
});
return like({
message,
diff: like({ changed: files.length, deletions: 0, insertions: 0, files }),
});
}