Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/utils / __tests__ / keep.test.ts
Size: Mime:
import 'jest'
import { keep } from '../src/keep'
import { keepOnly } from '../src/keepOnly'

describe('application/utils', () => {
  const obj = {
    one: 1,
    two: 2,
  }

  function expectKept(kept: Partial<typeof obj>) {
    // removed a property
    expect(Object.keys(kept).length).toEqual(1)
    expect(kept.two).toEqual(2)
    expect(kept.one).toEqual(undefined)

    // did not mutate
    expect(obj.two).toEqual(2)
  }

  it('should keep only the props we list', () => {
    expect.assertions(4)
    const kept = keep(obj, ['two'])
    expectKept(kept)
  })

  it('should keepOnly props we list', () => {
    expect.assertions(4)
    const keepTwo = keepOnly(['two'])
    const kept = keepTwo(obj)
    expectKept(kept)
  })
})