mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-03 02:42:05 +00:00
Add tests for 'filterObjectProps'
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
import { omitProps, pickProps } from '.';
|
||||||
|
import assert from 'assert';
|
||||||
|
import React from 'react/addons';
|
||||||
|
|
||||||
|
suite('pickProps', () => {
|
||||||
|
test('interface', () => {
|
||||||
|
assert.throws(
|
||||||
|
() => { pickProps({}, true); },
|
||||||
|
TypeError,
|
||||||
|
'pickProps should throw if the second argument is not an array'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('return value', () => {
|
||||||
|
const obj = { a: 1, b: 2, c: { cc: { ccc: 3 } } };
|
||||||
|
const props = [ 'a', 'b' ];
|
||||||
|
const expected = { a: 1, b: 2 };
|
||||||
|
const actual = pickProps(obj, props);
|
||||||
|
|
||||||
|
assert.deepEqual(actual, expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
suite('omitProps', () => {
|
||||||
|
test('interface', () => {
|
||||||
|
assert.throws(
|
||||||
|
() => { omitProps({}, true); },
|
||||||
|
TypeError,
|
||||||
|
'omitProps should throw if the second argument is not an array'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('return value', () => {
|
||||||
|
const obj = { a: 1, b: 2, c: { cc: { ccc: 3 } } };
|
||||||
|
const props = [ 'a', 'b' ];
|
||||||
|
const expected = { c: { cc: { ccc: 3 } } };
|
||||||
|
const actual = omitProps(obj, props);
|
||||||
|
|
||||||
|
assert.deepEqual(actual, expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user