license import { omit } from "../index" ; describe ( "omit" , ( ) => { it ( "should return source object reference on empty keys" , ( ) => { const state = { a : "hello" } ; const result = omit ( state , [ ] ) ; expect ( result ) . toBe ( state ) ; } ) ; it ( "should return source object reference on non-overlapping keys" , ( ) => { const state = { a : "hello" } as { [ key ] : string ; } ; const result = omit ( state , [ "b" , "c" ] ) ; expect ( result ) . toBe ( state ) ; } ) ; it ( "should remove an included key" , ( ) => { const state = { a : "hello" , b : "world" } ; const result = omit ( state , [ "b" ] ) ; expect ( result ) . toEqual ( { a : "hello" } ) ; } ) ; it ( "should remove only included keys" , ( ) => { const state = { a : "hello" , b : "world" } as Record < "a" | "b" | "c" , string > ; const result = omit ( state , [ "b" , "c" ] ) ; expect ( result ) . toEqual ( { a : "hello" } ) ; } ) ; it ( "should remove all included keys" , ( ) => { const state = { a : "hello" , b : "world" , c : "!" } ; const result = omit ( state , [ "a" , "b" ] ) ; expect ( result ) . toEqual ( { c : "!" } ) ; } ) ; it ( "should allow empty object return" , ( ) => { const state = { a : "hello" , b : "world" , c : "!" } ; const result = omit ( state , [ "a" , "b" , "c" ] ) ; expect ( result ) . toEqual ( { } ) ; } ) ; it ( "should not mutate source objects" , ( ) => { const state = { a : "hello" , b : "world" , c : "!" } ; omit ( state , [ "a" , "b" , "c" ] ) ; expect ( state ) . toEqual ( { a : "hello" , b : "world" , c : "!" } ) ; } ) ; it ( "should treat `undefined` removals as updates" , ( ) => { const state = { a : "hello" , b : "world" , c : undefined } ; const result = omit ( state , [ "c" ] ) ; expect ( result ) . not . toBe ( state ) ; expect ( Object . prototype . hasOwnProperty . call ( result , "c" ) ) . toBe ( false ) ; } ) ; } ) ;