@@ -65,6 +65,28 @@ describe('services iffElse', () => {
65
65
hookFcnAsyncCalls = 0 ;
66
66
} ) ;
67
67
68
+ describe ( 'runs single hook' , ( ) => {
69
+ it ( 'when true' , ( ) => {
70
+ return hooks . iffElse ( true , hookFcnSync , hookFcnAsync ) ( hook )
71
+ . then ( hook => {
72
+ assert . deepEqual ( hook , hookAfter ) ;
73
+ assert . equal ( hookFcnSyncCalls , 1 ) ;
74
+ assert . equal ( hookFcnAsyncCalls , 0 ) ;
75
+ assert . deepEqual ( hook , hookAfter ) ;
76
+ } ) ;
77
+ } ) ;
78
+
79
+ it ( 'when false' , ( ) => {
80
+ return hooks . iffElse ( false , hookFcnSync , hookFcnAsync ) ( hook )
81
+ . then ( hook => {
82
+ assert . deepEqual ( hook , hookAfter ) ;
83
+ assert . equal ( hookFcnSyncCalls , 0 ) ;
84
+ assert . equal ( hookFcnAsyncCalls , 1 ) ;
85
+ assert . deepEqual ( hook , hookAfter ) ;
86
+ } ) ;
87
+ } ) ;
88
+ } ) ;
89
+
68
90
describe ( 'runs multiple hooks' , ( ) => {
69
91
it ( 'when true' , ( ) => {
70
92
return hooks . iffElse ( true , [ hookFcnSync , hookFcnAsync , hookFcnCb ] , null ) ( hook )
@@ -154,6 +176,6 @@ describe('services iffElse', () => {
154
176
155
177
// Helpers
156
178
157
- function clone ( obj ) {
179
+ function clone ( obj ) {
158
180
return JSON . parse ( JSON . stringify ( obj ) ) ;
159
181
}
0 commit comments