-
-
Notifications
You must be signed in to change notification settings - Fork 313
/
status.spec.ts
65 lines (54 loc) · 2.01 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import {
createTestContext,
like,
newSimpleGit,
setUpFilesAdded,
setUpInit,
SimpleGitTestContext
} from '../__fixtures__';
describe('status', () => {
let context: SimpleGitTestContext;
beforeEach(async () => context = await createTestContext());
beforeEach(async () => {
await setUpInit(context);
await context.file(['clean-dir', 'clean']);
await context.file(['dirty-dir', 'dirty']);
await setUpFilesAdded(context, ['alpha', 'beta'], ['alpha', 'beta', './clean-dir']);
});
it('whole repo status', async () => {
const status = await newSimpleGit(context.root).status();
expect(status).toHaveProperty('not_added', ['dirty-dir/dirty']);
});
it('clean pathspec in options array', async () => {
const status = await newSimpleGit(context.root).status(['--', 'clean-dir']);
expect(status.isClean()).toBe(true);
expect(status.files).toEqual([]);
});
it('dirty pathspec in options array', async () => {
const status = await newSimpleGit(context.root).status(['--', 'dirty-dir']);
expect(status.isClean()).toBe(false);
expect(status.not_added).toEqual(['dirty-dir/dirty']);
});
it('clean pathspec in options object', async () => {
const status = await newSimpleGit(context.root).status({'--': null, 'clean-dir': null});
expect(status.isClean()).toBe(true);
});
it('dirty pathspec in options object', async () => {
const status = await newSimpleGit(context.root).status({'--': null, 'dirty-dir': null});
expect(status.isClean()).toBe(false);
expect(status.not_added).toEqual(['dirty-dir/dirty']);
});
it('detached head', async () => {
const git = newSimpleGit(context.root);
expect(await git.status()).toEqual(like({
detached: false,
current: expect.any(String),
}));
await git.raw('tag', 'v1');
await git.raw('checkout', 'v1');
expect(await git.status()).toEqual(like({
current: 'HEAD',
detached: true,
}))
})
});