-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
41 lines (34 loc) · 1.4 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
require('mocha');
var hbs = require('handlebars');
var assert = require('assert');
var and = require('./');
describe('handlebars-helper-and', function() {
beforeEach(function() {
hbs.registerHelper('and', and);
});
describe('block', function() {
it('should render a block if both values are truthy.', function() {
var fn = hbs.compile('{{#and great magnificent}}A{{else}}B{{/and}}');
assert.equal(fn({ great: true, magnificent: true }), 'A');
});
it('should render the inverse block if both values are not truthy.', function() {
var fn = hbs.compile('{{#and great magnificent}}A{{else}}B{{/and}}');
assert.equal(fn({ great: true, magnificent: false }), 'B');
});
});
describe('inline or subexpression', function() {
it('should render a block if both values are truthy.', function() {
var fn = hbs.compile('{{and great magnificent}}');
assert.equal(fn({ great: true, magnificent: true }), 'true');
});
it('should render the inverse block if both values are not truthy.', function() {
var fn = hbs.compile('{{and great magnificent}}');
assert.equal(fn({ great: true, magnificent: false }), 'false');
});
it('should work as subexpressions', function() {
var fn = hbs.compile('{{and (and a b) (and great magnificent)}}');
assert.equal(fn({ great: true, magnificent: false }), 'false');
});
});
});