Skip to content

Commit 56c2fec

Browse files
committed
100% test coverage on iffelse
1 parent 9e5474e commit 56c2fec

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/services/iffelse.test.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,28 @@ describe('services iffElse', () => {
6565
hookFcnAsyncCalls = 0;
6666
});
6767

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+
6890
describe('runs multiple hooks', () => {
6991
it('when true', () => {
7092
return hooks.iffElse(true, [hookFcnSync, hookFcnAsync, hookFcnCb], null)(hook)
@@ -154,6 +176,6 @@ describe('services iffElse', () => {
154176

155177
// Helpers
156178

157-
function clone (obj) {
179+
function clone(obj) {
158180
return JSON.parse(JSON.stringify(obj));
159181
}

0 commit comments

Comments
 (0)