@@ -53,4 +53,28 @@ describe('spread operator', () => {
5353 expect ( formatBook ( ...values ) ) . toEqual ( 'Reasons and Persons by Derek Parfit $19.99' ) ;
5454 expect ( formatBook ( ...Object . values ( book ) ) ) . toEqual ( 'Reasons and Persons by Derek Parfit $19.99' ) ;
5555 } ) ;
56+
57+ it ( 'should not modify with a loop' , ( ) => {
58+ const before = [ 'apple' , 'banana' , 'orange' ] ;
59+ const after = [ 'apple' , 'banana' , 'orange' ] ;
60+ expect ( removeItemProblem ( before , 'peach' ) ) . toEqual ( after ) ;
61+ } ) ;
62+
63+ it ( 'should not modify with a slice' , ( ) => {
64+ const before = [ 'apple' , 'banana' , 'orange' ] ;
65+ const after = [ 'apple' , 'banana' , 'orange' ] ;
66+ expect ( removeItemSlice ( before , 'peach' ) ) . toEqual ( after ) ;
67+ } ) ;
68+
69+ it ( 'should not modify with a splice' , ( ) => {
70+ const before = [ 'apple' , 'banana' , 'orange' ] ;
71+ const after = [ 'apple' , 'banana' , 'orange' ] ;
72+ expect ( removeItemSplice ( before , 'peach' ) ) . toEqual ( after ) ;
73+ } ) ;
74+
75+ it ( 'should not modify with a spread' , ( ) => {
76+ const before = [ 'apple' , 'banana' , 'orange' ] ;
77+ const after = [ 'apple' , 'banana' , 'orange' ] ;
78+ expect ( removeItem ( before , 'peach' ) ) . toEqual ( after ) ;
79+ } ) ;
5680} ) ;
0 commit comments