UNPKG

base-repository

Version:

[![Build Status](https://travis-ci.org/joehua87/base-repository.svg?branch=master)](https://travis-ci.org/joehua87/base-repository)

29 lines (24 loc) 835 B
import { expect } from 'chai' import omitDeep from '../../../src/nest-omit' describe('Omit nested', () => { it('1 level', () => { const obj = { a: 'a', b: 'b' } const returnObj = omitDeep(obj, 'a') expect(returnObj).to.deep.equal({ b: 'b' }) }) it('nested object', () => { const obj = { a: 'a', b: { c: 'c' } } const returnObj = omitDeep(obj, 'c') expect(returnObj).to.deep.equal({ a: 'a', b: {} }) }) it('nested array', () => { const obj = { a: 'a', b: [{ c: 'c', d: 'd' }] } const returnObj = omitDeep(obj, 'c') expect(returnObj).to.deep.equal({ a: 'a', b: [{ d: 'd' }] }) }) it('array in top level', () => { const obj = [{ a: 'a', b: [{ c: 'c', d: 'd' }] }] const returnObj = omitDeep(obj, 'c') expect(returnObj).to.deep.equal([{ a: 'a', b: [{ d: 'd' }] }]) }) })