UNPKG

5.12 kBJavaScriptView Raw
1(function() {
2 var Assemble, Handlebars;
3
4 require('should');
5
6 Handlebars = require('handlebars');
7
8 Assemble = require('../lib/helpers-lib');
9
10 describe('is', function() {
11 return describe('{{#is bender "great"}} \n\
12 Kiss my shiny metal ass! \n\
13 {{else}} \n\
14 Never mind :( \n\
15 {{/is}}', function() {
16 return it('should render a block if the condition is true.', function() {
17 var context, source, template;
18
19 source = '{{#is bender "great"}}Kiss my shiny metal ass!{{else}}Never mind :({{/is}}';
20 template = Handlebars.compile(source);
21 context = {
22 bender: 'great'
23 };
24 return template(context).should.equal('Kiss my shiny metal ass!');
25 });
26 });
27 });
28
29 describe('isnt', function() {
30 return describe('{{#isnt number 2}} \n\
31 Kiss my great metal ass! \n\
32 {{else}} \n\
33 Never mind :( \n\
34 {{/isnt}}', function() {
35 return it('should render a block if the condition is not true.', function() {
36 var context, source, template;
37
38 source = '{{#isnt number 2}}Kiss my great metal ass!{{else}}Never mind :({{/isnt}}';
39 template = Handlebars.compile(source);
40 context = {
41 number: 3
42 };
43 return template(context).should.equal('Kiss my great metal ass!');
44 });
45 });
46 });
47
48 describe('gt', function() {
49 return describe('{{#gt number 8}} \n\
50 Kiss my glorious metal ass! \n\
51 {{else}} \n\
52 Never mind :( \n\
53 {{/gt}}', function() {
54 return it('should render a block if the value is greater than a given number.', function() {
55 var context, source, template;
56
57 source = '{{#gt number 8}}Kiss my glorious metal ass!{{else}}Never mind :({{/gt}}';
58 template = Handlebars.compile(source);
59 context = {
60 number: 9
61 };
62 return template(context).should.equal('Kiss my glorious metal ass!');
63 });
64 });
65 });
66
67 describe('gte', function() {
68 return describe('{{#gte number 8}} \n\
69 Kiss my perfect metal ass! \n\
70 {{else}} \n\
71 Never mind :( \n\
72 {{/gte}}', function() {
73 return it('should render a block if the value is greater or equal than a given number.', function() {
74 var context, source, template;
75
76 source = '{{#gte number 8}}Kiss my perfect metal ass!{{else}}Never mind :({{/gte}}';
77 template = Handlebars.compile(source);
78 context = {
79 number: 8
80 };
81 return template(context).should.equal('Kiss my perfect metal ass!');
82 });
83 });
84 });
85
86 describe('lt', function() {
87 return describe('{{#lt number 8}} \n\
88 Kiss my golden metal ass! \n\
89 {{else}} \n\
90 Never mind :( \n\
91 {{/lt}}', function() {
92 return it('should render a block if the value is less than a given number.', function() {
93 var context, source, template;
94
95 source = '{{#lt number 8}}Kiss my golden metal ass!{{else}}Never mind :({{/lt}}';
96 template = Handlebars.compile(source);
97 context = {
98 number: 2
99 };
100 return template(context).should.equal('Kiss my golden metal ass!');
101 });
102 });
103 });
104
105 describe('lte', function() {
106 return describe('{{#lte number 8}} \n\
107 Kiss my big metal ass! \n\
108 {{else}} \n\
109 Never mind :( \n\
110 {{/lte}}', function() {
111 return it('should render a block if the value is less or equal than a given number.', function() {
112 var context, source, template;
113
114 source = '{{#lte number 8}}Kiss my big metal ass!{{else}}Never mind :({{/lte}}';
115 template = Handlebars.compile(source);
116 context = {
117 number: 8
118 };
119 return template(context).should.equal('Kiss my big metal ass!');
120 });
121 });
122 });
123
124 describe('or', function() {
125 return describe('{{#or great magnificent}} \n\
126 Kiss my perfect metal ass! \n\
127 {{else}} \n\
128 Never mind :( \n\
129 {{/or}}', function() {
130 return it('should render a block if one of the values is truthy.', function() {
131 var context, source, template;
132
133 source = '{{#or great magnificent}}Kiss my perfect metal ass!{{else}}Never mind :({{/or}}';
134 template = Handlebars.compile(source);
135 context = {
136 great: false,
137 magnificent: true
138 };
139 return template(context).should.equal('Kiss my perfect metal ass!');
140 });
141 });
142 });
143
144 describe('and', function() {
145 return describe('{{#and great magnificent}} \n\
146 Kiss my glorious metal ass! \n\
147 {{else}} \n\
148 Never mind :( \n\
149 {{/and}}', function() {
150 return it('should render a block if both values are truthy.', function() {
151 var context, source, template;
152
153 source = '{{#and great magnificent}}Kiss my glorious metal ass!{{else}}Never mind :({{/and}}';
154 template = Handlebars.compile(source);
155 context = {
156 great: true,
157 magnificent: true
158 };
159 return template(context).should.equal('Kiss my glorious metal ass!');
160 });
161 });
162 });
163
164}).call(this);