@@ -166,28 +166,6 @@ describe('shimmer', () => {
166166 expect ( count ) . to . have . property ( 'enumerable' , false )
167167 } )
168168
169- it ( 'should unwrap a method' , ( ) => {
170- const count = inc => inc
171- const obj = { count }
172-
173- shimmer . wrap ( obj , 'count' , count => inc => count ( inc ) + 1 )
174- shimmer . unwrap ( obj , 'count' )
175-
176- expect ( obj . count ( 1 ) ) . to . equal ( 1 )
177- } )
178-
179- it ( 'should unwrap a method from the prototype' , ( ) => {
180- const count = inc => inc
181- const obj = { }
182-
183- Object . setPrototypeOf ( obj , { count } )
184-
185- shimmer . wrap ( obj , 'count' , count => inc => count ( inc ) + 1 )
186- shimmer . unwrap ( obj , 'count' )
187-
188- expect ( obj ) . to . not . have . ownProperty ( 'count' )
189- } )
190-
191169 it ( 'should validate that there is a target object' , ( ) => {
192170 expect ( ( ) => shimmer . wrap ( ) ) . to . throw ( )
193171 } )
@@ -212,22 +190,6 @@ describe('shimmer', () => {
212190 expect ( ( ) => shimmer . wrap ( { a : ( ) => { } } , 'a' , 'notafunction' ) ) . to . throw ( )
213191 } )
214192
215- it ( 'should not throw when unwrapping without a target' , ( ) => {
216- expect ( ( ) => shimmer . unwrap ( null , 'a' ) ) . to . not . throw ( )
217- } )
218-
219- it ( 'should not throw when unwrapping without a method' , ( ) => {
220- expect ( ( ) => shimmer . unwrap ( { } , 'a' ) ) . to . not . throw ( )
221- } )
222-
223- it ( 'should not throw when unwrapping an invalid type' , ( ) => {
224- expect ( ( ) => shimmer . unwrap ( { a : 'b' } , 'a' ) ) . to . not . throw ( )
225- } )
226-
227- it ( 'should not throw when unwrapping a method that was not wrapped' , ( ) => {
228- expect ( ( ) => shimmer . unwrap ( { a : ( ) => { } } , 'a' ) ) . to . not . throw ( )
229- } )
230-
231193 describe ( 'safe mode' , ( ) => {
232194 let obj
233195
@@ -539,34 +501,6 @@ describe('shimmer', () => {
539501 expect ( Object . getOwnPropertyNames ( wrapped ) ) . to . not . include ( 'test' )
540502 } )
541503
542- it ( 'should unwrap a function' , ( ) => {
543- const count = inc => inc
544-
545- const wrapped = shimmer . wrapFunction ( count , count => inc => count ( inc ) + 1 )
546-
547- shimmer . unwrap ( wrapped )
548-
549- expect ( wrapped ( 1 ) ) . to . equal ( 1 )
550- } )
551-
552- it ( 'should unwrap a constructor' , ( ) => {
553- const Counter = function ( start ) {
554- this . value = start
555- }
556-
557- const WrappedCounter = shimmer . wrapFunction ( Counter , Counter => function ( ...args ) {
558- Counter . apply ( this , arguments )
559- this . value ++
560- } )
561-
562- shimmer . unwrap ( WrappedCounter )
563-
564- const counter = new WrappedCounter ( 1 )
565-
566- expect ( counter . value ) . to . equal ( 1 )
567- expect ( counter ) . to . be . an . instanceof ( Counter )
568- } )
569-
570504 it ( 'should mass wrap methods on objects' , ( ) => {
571505 const foo = {
572506 a : ( ) => 'original' ,
@@ -586,44 +520,12 @@ describe('shimmer', () => {
586520 expect ( bar . b ( ) ) . to . equal ( 'wrapped' )
587521 } )
588522
589- it ( 'should mass wrap methods on objects' , ( ) => {
590- const foo = {
591- a : ( ) => 'original' ,
592- b : ( ) => 'original'
593- }
594-
595- const bar = {
596- a : ( ) => 'original' ,
597- b : ( ) => 'original'
598- }
599-
600- shimmer . massWrap ( [ foo , bar ] , [ 'a' , 'b' ] , ( ) => ( ) => 'wrapped' )
601- shimmer . massUnwrap ( [ foo , bar ] , [ 'a' , 'b' ] )
602-
603- expect ( foo . a ( ) ) . to . equal ( 'original' )
604- expect ( foo . b ( ) ) . to . equal ( 'original' )
605- expect ( bar . a ( ) ) . to . equal ( 'original' )
606- expect ( bar . b ( ) ) . to . equal ( 'original' )
607- } )
608-
609523 it ( 'should validate that the function wrapper exists' , ( ) => {
610524 expect ( ( ) => shimmer . wrap ( ( ) => { } ) ) . to . throw ( )
611525 } )
612526
613527 it ( 'should validate that the function wrapper is a function' , ( ) => {
614528 expect ( ( ) => shimmer . wrap ( ( ) => { } , 'a' ) ) . to . throw ( )
615529 } )
616-
617- it ( 'should never throw when unwrapping' , ( ) => {
618- expect ( ( ) => shimmer . unwrap ( ( ) => { } ) ) . to . not . throw ( )
619- } )
620-
621- it ( 'should not throw when unwrapping an invalid type' , ( ) => {
622- expect ( ( ) => shimmer . unwrap ( 'foo' ) ) . to . not . throw ( )
623- } )
624-
625- it ( 'should not throw when unwrapping a function that was not wrapped' , ( ) => {
626- expect ( ( ) => shimmer . unwrap ( ( ) => { } ) ) . to . not . throw ( )
627- } )
628530 } )
629531} )
0 commit comments