Skip to content

Commit 31ef162

Browse files
committed
write tests for isTruthy/isFalsey and add link to them in README.md
1 parent da6613e commit 31ef162

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ Visit the: [code](lib/comparison.js) | [unit tests](test/comparison.js) | [issue
166166
* **[gt](#gt)** ([code](lib/comparison.js#L182) | [tests](test/comparison.js#L214))
167167
* **[gte](#gte)** ([code](lib/comparison.js#L206) | [tests](test/comparison.js#L245))
168168
* **[has](#has)** ([code](lib/comparison.js#L226) | [tests](test/comparison.js#L260))
169-
* **[isFalsey](#isFalsey)** ([code](lib/comparison.js#L268) | [no tests])
170-
* **[isTruthy](#isTruthy)** ([code](lib/comparison.js#L283) | [no tests])
169+
* **[isFalsey](#isFalsey)** ([code](lib/comparison.js#L268) | [tests](test/comparison.js#L327))
170+
* **[isTruthy](#isTruthy)** ([code](lib/comparison.js#L283) | [tests](test/comparison.js#L339))
171171
* **[ifEven](#ifEven)** ([code](lib/comparison.js#L304) | [tests](test/comparison.js#L344))
172172
* **[ifNth](#ifNth)** ([code](lib/comparison.js#L321) | [tests](test/comparison.js#L356))
173173
* **[ifOdd](#ifOdd)** ([code](lib/comparison.js#L344) | [tests](test/comparison.js#L379))

test/comparison.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,30 @@ describe('comparison', function() {
324324
});
325325
});
326326

327+
describe('isFalsey', function() {
328+
it('should render block if given value is falsey.', function() {
329+
var fn = hbs.compile('{{#if (isFalsey value)}}A{{else}}B{{/if}}');
330+
assert.equal(fn({value: 'nope'}), 'A');
331+
});
332+
333+
it('should render inverse if given value is truthy', function() {
334+
var fn = hbs.compile('{{#if (isFalsey value)}}A{{else}}B{{/if}}');
335+
assert.equal(fn({value: 'CCC'}), 'B');
336+
});
337+
});
338+
339+
describe('isTruthy', function() {
340+
it('should render block if given value is truthy.', function() {
341+
var fn = hbs.compile('{{#if (isTruthy value)}}A{{else}}B{{/if}}');
342+
assert.equal(fn({value: 'CCC'}), 'A');
343+
});
344+
345+
it('should render inverse if given value is not truthy', function() {
346+
var fn = hbs.compile('{{#if (isTruthy value)}}A{{else}}B{{/if}}');
347+
assert.equal(fn({value: 'nope'}), 'B');
348+
});
349+
});
350+
327351
describe('eq', function() {
328352
it('should render a block if the value is equal to a given number.', function() {
329353
var fn = hbs.compile('{{#eq number compare=8}}A{{/eq}}');

0 commit comments

Comments
 (0)