apphouse
Version:
Component library for React that uses observable state management and theme-able components.
51 lines (48 loc) • 1.09 kB
text/typescript
import { omitAll } from './omitAll';
describe('omitAll', () => {
test('should omit all keys from an object', () => {
const obj = {
name: 'John',
__typename: {
name: 'John'
}
};
const newObj = omitAll(obj, ['__typename']);
expect(newObj).toEqual({
name: 'John'
});
});
test('should omit all keys recursively from an object', () => {
const obj = {
name: 'John',
__typename: {
name: 'John'
},
address: {
__typename: {
name: 'John'
},
city: 'New York',
country: 'USA'
}
};
const newObj = omitAll(obj, ['__typename']);
expect(newObj).toEqual({
name: 'John',
address: {
city: 'New York',
country: 'USA'
}
});
});
test('should omit all keys in the array from an object', () => {
const obj = {
name: 'John',
age: 25,
city: 'New York',
country: 'USA'
};
const newObj = omitAll(obj, ['name', 'age', 'city', 'country']);
expect(newObj).toEqual({});
});
});