-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathdarwin.test.ts
48 lines (40 loc) · 1.42 KB
/
darwin.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
import * as os from 'os';
import * as path from 'path';
import { fixtureDir } from '../common';
import { inspect } from '../../lib';
import * as subProcess from '../../lib/sub-process';
const rootNoWrapper = fixtureDir('no wrapper');
const rootWithWrapper = fixtureDir('with-wrapper');
const subWithWrapper = fixtureDir('with-wrapper-in-root');
let subProcessExecSpy;
let platformMock;
beforeAll(() => {
platformMock = jest.spyOn(os, 'platform');
platformMock.mockReturnValue('darwin');
subProcessExecSpy = jest.spyOn(subProcess, 'execute');
subProcessExecSpy.mockRejectedValue(new Error('fake process aborted'));
});
afterEach(() => {
jest.clearAllMocks();
});
afterAll(() => {
jest.restoreAllMocks();
});
test('darwin without wrapper invokes gradle directly', async () => {
await expect(inspect(rootNoWrapper, 'build.gradle')).rejects.toThrow();
expect(subProcessExecSpy.mock.calls[0][0]).toBe('gradle');
});
test('darwin with wrapper invokes wrapper script', async () => {
await expect(inspect(rootWithWrapper, 'build.gradle')).rejects.toThrow();
expect(subProcessExecSpy.mock.calls[0][0]).toBe(
path.join(rootWithWrapper, 'gradlew'),
);
});
test('darwin with wrapper in root invokes wrapper script', async () => {
await expect(
inspect(subWithWrapper, path.join('app', 'build.gradle')),
).rejects.toThrow();
expect(subProcessExecSpy.mock.calls[0][0]).toBe(
path.join(subWithWrapper, 'gradlew'),
);
});