File tree 1 file changed +46
-0
lines changed
1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -626,6 +626,52 @@ module.exports = {
626
626
should . strictEqual ( undefined , a . preValueOne ) ;
627
627
should . strictEqual ( undefined , a . preValueTwo ) ;
628
628
} ,
629
+
630
+ 'should be able to remove a particular post' : function ( ) {
631
+ var A = function ( ) { }
632
+ , postTwo ;
633
+ _ . extend ( A , hooks ) ;
634
+ A . hook ( 'save' , function ( ) {
635
+ this . value = 1 ;
636
+ } ) ;
637
+ A . post ( 'save' , function ( next ) {
638
+ this . postValueOne = 2 ;
639
+ next ( ) ;
640
+ } ) ;
641
+ A . post ( 'save' , postTwo = function ( next ) {
642
+ this . postValueTwo = 4 ;
643
+ next ( ) ;
644
+ } ) ;
645
+ A . removePost ( 'save' , postTwo ) ;
646
+ var a = new A ( ) ;
647
+ a . save ( ) ;
648
+ a . value . should . equal ( 1 ) ;
649
+ a . postValueOne . should . equal ( 2 ) ;
650
+ should . strictEqual ( undefined , a . postValueTwo ) ;
651
+ } ,
652
+
653
+ 'should be able to remove all posts associated with a hook' : function ( ) {
654
+ var A = function ( ) { } ;
655
+ _ . extend ( A , hooks ) ;
656
+ A . hook ( 'save' , function ( ) {
657
+ this . value = 1 ;
658
+ } ) ;
659
+ A . post ( 'save' , function ( next ) {
660
+ this . postValueOne = 2 ;
661
+ next ( ) ;
662
+ } ) ;
663
+ A . post ( 'save' , function ( next ) {
664
+ this . postValueTwo = 4 ;
665
+ next ( ) ;
666
+ } ) ;
667
+ A . removePost ( 'save' ) ;
668
+ var a = new A ( ) ;
669
+ a . save ( ) ;
670
+ a . value . should . equal ( 1 ) ;
671
+ should . strictEqual ( undefined , a . postValueOne ) ;
672
+ should . strictEqual ( undefined , a . postValueTwo ) ;
673
+ } ,
674
+
629
675
630
676
'#pre should lazily make a method hookable' : function ( ) {
631
677
var A = function ( ) { } ;
You can’t perform that action at this time.
0 commit comments