File tree Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -166,8 +166,8 @@ Visit the: [code](lib/comparison.js) | [unit tests](test/comparison.js) | [issue
166
166
* ** [ gt] ( #gt ) ** ([ code] ( lib/comparison.js#L182 ) | [ tests] ( test/comparison.js#L214 ) )
167
167
* ** [ gte] ( #gte ) ** ([ code] ( lib/comparison.js#L206 ) | [ tests] ( test/comparison.js#L245 ) )
168
168
* ** [ 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 ) )
171
171
* ** [ ifEven] ( #ifEven ) ** ([ code] ( lib/comparison.js#L304 ) | [ tests] ( test/comparison.js#L344 ) )
172
172
* ** [ ifNth] ( #ifNth ) ** ([ code] ( lib/comparison.js#L321 ) | [ tests] ( test/comparison.js#L356 ) )
173
173
* ** [ ifOdd] ( #ifOdd ) ** ([ code] ( lib/comparison.js#L344 ) | [ tests] ( test/comparison.js#L379 ) )
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ require('kind-of', 'typeOf');
18
18
// matching utils
19
19
require ( 'is-glob' ) ;
20
20
require ( 'micromatch' , 'mm' ) ;
21
+ require ( 'falsey' ) ;
21
22
22
23
// Number utils
23
24
require ( 'is-even' ) ;
Original file line number Diff line number Diff line change 72
72
"array-sort" : " ^0.1.2" ,
73
73
"create-frame" : " ^1.0.0" ,
74
74
"define-property" : " ^1.0.0" ,
75
+ "falsey" : " ^0.3.0" ,
75
76
"for-in" : " ^1.0.2" ,
76
77
"for-own" : " ^1.0.0" ,
77
78
"get-object" : " ^0.2.0" ,
Original file line number Diff line number Diff line change @@ -324,6 +324,30 @@ describe('comparison', function() {
324
324
} ) ;
325
325
} ) ;
326
326
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
+
327
351
describe ( 'eq' , function ( ) {
328
352
it ( 'should render a block if the value is equal to a given number.' , function ( ) {
329
353
var fn = hbs . compile ( '{{#eq number compare=8}}A{{/eq}}' ) ;
You can’t perform that action at this time.
0 commit comments