mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-06-03 05:10:47 +00:00
6fb3b92eb8
* Update deps except eslint * Update eslint and lint:fix (WIP, needs manual fixing for remaining 44 problems) * Manually fix remaining eslint errors * Document deprecation of `version-string` as of electron-packager 9.0.0 * Upgrade to Electron 1.7.9 (chrome-58, node-7.9.0, v8-5.8) * npm: Disable generation of package-lock.json and gitignore it --Trying this, package-lock is a pain in PRs. May not be a good idea (obviously we lose deps pinning), will revert if necessary.-- * npm tasks: add dev-up-win for Windows developers, and e2e for end-to-end tests. Update docs. * Move normalizeUrl test to a jest unit test, makes no sense to be in the mocha e2e tests * Switch from babel-preset-es2015 to babel-preset-env, with target.node=4.0. Seem like it's today's most convenient way to support the latest ES and let babel transpile to what makes sense for our currently minimal node version
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import log from 'loglevel';
|
|
import icon from './icon';
|
|
import { inferIcon } from './../../infer';
|
|
|
|
jest.mock('./../../infer/inferIcon');
|
|
jest.mock('loglevel');
|
|
|
|
const mockedResult = 'icon path';
|
|
|
|
describe('when the icon parameter is passed', () => {
|
|
test('it should return the icon parameter', () => {
|
|
expect(inferIcon).toHaveBeenCalledTimes(0);
|
|
|
|
const params = { icon: './icon.png' };
|
|
expect(icon(params)).resolves.toBe(params.icon);
|
|
});
|
|
});
|
|
|
|
describe('when the icon parameter is not passed', () => {
|
|
test('it should call inferIcon', () => {
|
|
inferIcon.mockImplementationOnce(() => Promise.resolve(mockedResult));
|
|
const params = { targetUrl: 'some url', platform: 'mac' };
|
|
|
|
return icon(params).then((result) => {
|
|
expect(result).toBe(mockedResult);
|
|
expect(inferIcon).toHaveBeenCalledWith(params.targetUrl, params.platform);
|
|
});
|
|
});
|
|
|
|
describe('when inferIcon resolves with an error', () => {
|
|
test('it should handle the error', () => {
|
|
inferIcon.mockImplementationOnce(() => Promise.reject(new Error('some error')));
|
|
const params = { targetUrl: 'some url', platform: 'mac' };
|
|
|
|
return icon(params).then((result) => {
|
|
expect(result).toBe(null);
|
|
expect(inferIcon).toHaveBeenCalledWith(params.targetUrl, params.platform);
|
|
expect(log.warn).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|
|
});
|
|
});
|