-
Notifications
You must be signed in to change notification settings - Fork 29
/
push.test.ts
54 lines (47 loc) 路 1.26 KB
/
push.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
54
import git from 'isomorphic-git';
import { push } from './push';
jest.mock('isomorphic-git');
afterEach(jest.resetAllMocks);
describe('push', () => {
it('propagates props to isomorphic-git', async () => {
jest
.mocked(git.listRemotes)
.mockResolvedValue([
{ remote: 'origin', url: 'git@github.com:seek-oss/skuba.git' },
]);
jest.mocked(git.push).mockResolvedValue({
ok: true,
error: null,
refs: {},
});
await expect(
push({
auth: { token: 'abc', type: 'gitHubApp' },
dir: '/workdir/skuba',
ref: 'c'.repeat(40),
remoteRef: 'feature-a',
}),
).resolves.toStrictEqual({
error: null,
ok: true,
refs: {},
});
expect(git.push).toHaveBeenCalledTimes(1);
expect(jest.mocked(git.push).mock.calls[0][0]).toMatchInlineSnapshot(
{ http: expect.any(Object), fs: expect.any(Object) },
`
{
"dir": "/workdir/skuba",
"force": undefined,
"fs": Any<Object>,
"http": Any<Object>,
"onAuth": [Function],
"ref": "cccccccccccccccccccccccccccccccccccccccc",
"remote": undefined,
"remoteRef": "feature-a",
"url": "https://github.com/seek-oss/skuba",
}
`,
);
});
});