1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

Extended test cases and fixed bug

This commit is contained in:
Oliver foster 2019-12-19 12:00:46 +00:00
parent f27c7e0580
commit 5a6af193d2
2 changed files with 6 additions and 4 deletions

View File

@ -271,7 +271,7 @@ export default class Utils {
}
for (i = 0, l = assigners.length; i < l; i += 1) {
const assigner = assigners[i];
if (typeof assigner === 'object') {
if (typeof assigner === 'object' && assigner !== null) {
const keys = Object.keys(assigner);
keys.forEach((key) => {
result[key] = assigner[key];

View File

@ -107,9 +107,11 @@ test('find', (t) => {
t.is(result, 2);
const original = Array.prototype.find;
delete Array.prototype.find;
const polyfillResult = find([1,2], (value) => value==2);
const polyfillResultFound = find([1,2], (value) => value==2);
const polyfillResultNotFound = find([1,2], (value) => value==3);
Array.prototype.find = original;
t.is(polyfillResult, 2);
t.is(polyfillResultFound, 2);
t.is(polyfillResultNotFound, undefined);
});
test('assign', (t) => {
@ -119,7 +121,7 @@ test('assign', (t) => {
t.is(result['c'], 3);
const original = Object.assign;
delete Object.assign;
const polyfillResult = assign({}, { a: 1 }, { b: 1 }, { b: 2, c: 3 });
const polyfillResult = assign({}, { a: 1 }, { b: 1 }, null, { b: 2, c: 3 });
Object.assign = original;
t.is(polyfillResult['a'], 1);
t.is(polyfillResult['b'], 2);