2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-12-23 02:28:55 +00:00

Fix bug resolving promises

When a explicit argument is passed for `--icon` or `--user-agent`, the
promise chain will fail because we do not return a resolved promise.
This commit is contained in:
Jia Hao Goh 2017-05-19 20:50:09 +08:00
parent 0f0df27133
commit f91b2ba43d
5 changed files with 8 additions and 6 deletions

View File

@ -75,7 +75,7 @@
"gulp-mocha": "^4.3.0", "gulp-mocha": "^4.3.0",
"gulp-sourcemaps": "^2.6.0", "gulp-sourcemaps": "^2.6.0",
"isparta": "^4.0.0", "isparta": "^4.0.0",
"jest": "^19.0.2", "jest": "^20.0.3",
"regenerator-runtime": "^0.10.5", "regenerator-runtime": "^0.10.5",
"require-dir": "^0.3.0", "require-dir": "^0.3.0",
"run-sequence": "^1.1.5", "run-sequence": "^1.1.5",
@ -90,6 +90,8 @@
] ]
}, },
"jest": { "jest": {
"testMatch": ["**/src/**/?(*.)(spec|test).js?(x)"] "testMatch": [
"**/src/**/?(*.)(spec|test).js?(x)"
]
} }
} }

View File

@ -4,7 +4,7 @@ import { inferIcon } from './../../infer';
export default function ({ icon, targetUrl, platform }) { export default function ({ icon, targetUrl, platform }) {
// Icon is the path to the icon // Icon is the path to the icon
if (icon) { if (icon) {
return icon; return Promise.resolve(icon);
} }
return inferIcon(targetUrl, platform) return inferIcon(targetUrl, platform)

View File

@ -12,7 +12,7 @@ describe('when the icon parameter is passed', () => {
expect(inferIcon).toHaveBeenCalledTimes(0); expect(inferIcon).toHaveBeenCalledTimes(0);
const params = { icon: './icon.png' }; const params = { icon: './icon.png' };
expect(icon(params)).toBe(params.icon); expect(icon(params)).resolves.toBe(params.icon);
}); });
}); });

View File

@ -2,7 +2,7 @@ import { inferUserAgent } from './../../infer';
export default function ({ userAgent, electronVersion, platform }) { export default function ({ userAgent, electronVersion, platform }) {
if (userAgent) { if (userAgent) {
return userAgent; return Promise.resolve(userAgent);
} }
return inferUserAgent(electronVersion, platform); return inferUserAgent(electronVersion, platform);

View File

@ -7,7 +7,7 @@ test('when a userAgent parameter is passed', () => {
expect(inferUserAgent).toHaveBeenCalledTimes(0); expect(inferUserAgent).toHaveBeenCalledTimes(0);
const params = { userAgent: 'valid user agent' }; const params = { userAgent: 'valid user agent' };
expect(userAgent(params)).toBe(params.userAgent); expect(userAgent(params)).resolves.toBe(params.userAgent);
}); });
test('no userAgent parameter is passed', () => { test('no userAgent parameter is passed', () => {