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:
parent
f27c7e0580
commit
5a6af193d2
@ -271,7 +271,7 @@ export default class Utils {
|
|||||||
}
|
}
|
||||||
for (i = 0, l = assigners.length; i < l; i += 1) {
|
for (i = 0, l = assigners.length; i < l; i += 1) {
|
||||||
const assigner = assigners[i];
|
const assigner = assigners[i];
|
||||||
if (typeof assigner === 'object') {
|
if (typeof assigner === 'object' && assigner !== null) {
|
||||||
const keys = Object.keys(assigner);
|
const keys = Object.keys(assigner);
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
result[key] = assigner[key];
|
result[key] = assigner[key];
|
||||||
|
@ -107,9 +107,11 @@ test('find', (t) => {
|
|||||||
t.is(result, 2);
|
t.is(result, 2);
|
||||||
const original = Array.prototype.find;
|
const original = Array.prototype.find;
|
||||||
delete 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;
|
Array.prototype.find = original;
|
||||||
t.is(polyfillResult, 2);
|
t.is(polyfillResultFound, 2);
|
||||||
|
t.is(polyfillResultNotFound, undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('assign', (t) => {
|
test('assign', (t) => {
|
||||||
@ -119,7 +121,7 @@ test('assign', (t) => {
|
|||||||
t.is(result['c'], 3);
|
t.is(result['c'], 3);
|
||||||
const original = Object.assign;
|
const original = Object.assign;
|
||||||
delete 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;
|
Object.assign = original;
|
||||||
t.is(polyfillResult['a'], 1);
|
t.is(polyfillResult['a'], 1);
|
||||||
t.is(polyfillResult['b'], 2);
|
t.is(polyfillResult['b'], 2);
|
||||||
|
Loading…
Reference in New Issue
Block a user