ADD unzip support

This commit is contained in:
RecuencoJones
2020-03-21 11:34:19 +01:00
parent ea4cba1c34
commit 7e5607f443
6 changed files with 86 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ const common = require('../../src/common');
const install = require('../../src/actions/install');
const move = require('../../src/assets/move');
const untar = require('../../src/assets/untar');
const unzip = require('../../src/assets/unzip');
const verifyAndPlaceCallback = require('../../src/assets/binary');
jest.mock('fs');
@@ -12,6 +13,7 @@ jest.mock('request');
jest.mock('../../src/common');
jest.mock('../../src/assets/move');
jest.mock('../../src/assets/untar');
jest.mock('../../src/assets/unzip');
jest.mock('../../src/assets/binary');
describe('install()', () => {
@@ -77,6 +79,17 @@ describe('install()', () => {
expect(untar).toHaveBeenCalled();
});
it('should pick unzip strategy if url ends with .zip', () => {
request.mockReturnValueOnce(requestEvents);
common.parsePackageJson.mockReturnValueOnce({ url: 'http://url.zip' });
install(callback);
requestEvents.emit('response', { statusCode: 200 });
expect(unzip).toHaveBeenCalled();
});
it('should call verifyAndPlaceCallback on success', () => {
request.mockReturnValueOnce(requestEvents);
common.parsePackageJson.mockReturnValueOnce({ url: 'http://url', binName: 'command', binPath: './bin' });