-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathSetup.test.ts
More file actions
33 lines (28 loc) · 1.19 KB
/
Setup.test.ts
File metadata and controls
33 lines (28 loc) · 1.19 KB
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
import * as core from "@actions/core";
import * as tc from "@actions/tool-cache";
import Setup from "../src/Setup";
jest.mock('@actions/core');
describe('Setup.ts tests', () => {
afterEach(() => {
jest.restoreAllMocks();
})
it('sets up sqlcmd correctly', async() => {
const cacheLookupSpy = jest.spyOn(tc, 'find').mockReturnValue('');
const downloadToolSpy = jest.spyOn(tc, 'downloadTool').mockResolvedValue('');
const extractTarSpy = jest.spyOn(tc, 'extractTar').mockResolvedValue('');
const extractZipSpy = jest.spyOn(tc, 'extractZip').mockResolvedValue('');
const addPathSpy = jest.spyOn(core, 'addPath');
const cacheDirSpy = jest.spyOn(tc, 'cacheDir').mockResolvedValue('');
await Setup.setupSqlcmd();
expect(cacheLookupSpy).toHaveBeenCalled();
expect(downloadToolSpy).toHaveBeenCalled();
if (process.platform === 'win32') {
expect(extractZipSpy).toHaveBeenCalled();
}
else if (process.platform === 'linux') {
expect(extractTarSpy).toHaveBeenCalled();
}
expect(addPathSpy).toHaveBeenCalled();
expect(cacheDirSpy).toHaveBeenCalled();
});
})