UNPKG

2.82 kBJavaScriptView Raw
1(function() {
2 var Assemble, Handlebars, context;
3
4 require('should');
5
6 Handlebars = require('handlebars');
7
8 Assemble = require('../lib/helpers-lib');
9
10 context = {
11 value: 5
12 };
13
14 describe('add', function() {
15 return describe('{{add value 5}}', function() {
16 return it('should return the sum of two numbers.', function() {
17 var source, template;
18
19 source = '{{add value 5}}';
20 template = Handlebars.compile(source);
21 return template(context).should.equal(10);
22 });
23 });
24 });
25
26 describe('subtract', function() {
27 return describe('{{subtract value 5}}', function() {
28 return it('should return the difference of two numbers.', function() {
29 var source, template;
30
31 source = '{{subtract value 5}}';
32 template = Handlebars.compile(source);
33 return template(context).should.equal(0);
34 });
35 });
36 });
37
38 describe('divide', function() {
39 return describe('{{divide value 5}}', function() {
40 return it('should return the division of two numbers.', function() {
41 var source, template;
42
43 source = '{{divide value 5}}';
44 template = Handlebars.compile(source);
45 return template(context).should.equal(1);
46 });
47 });
48 });
49
50 describe('multiply', function() {
51 return describe('{{multiply value 5}}', function() {
52 return it('should return the multiplication of two numbers.', function() {
53 var source, template;
54
55 source = '{{multiply value 5}}';
56 template = Handlebars.compile(source);
57 return template(context).should.equal(25);
58 });
59 });
60 });
61
62 describe('floor', function() {
63 return describe('{{floor 5}}', function() {
64 return it('should return the value rounded down to the nearest integer.', function() {
65 var source, template;
66
67 source = '{{floor value}}';
68 template = Handlebars.compile(source);
69 return template(context = {
70 value: 5.6
71 }).should.equal(5);
72 });
73 });
74 });
75
76 describe('ceil', function() {
77 return describe('{{ceil 5}}', function() {
78 return it('should return the value rounded up to the nearest integer.', function() {
79 var source, template;
80
81 source = '{{ceil value}}';
82 template = Handlebars.compile(source);
83 return template(context = {
84 value: 5.6
85 }).should.equal(6);
86 });
87 });
88 });
89
90 describe('round', function() {
91 return describe('{{round 5}}', function() {
92 return it('should return the value rounded to the nearest integer.', function() {
93 var source, template;
94
95 source = '{{round value}}';
96 template = Handlebars.compile(source);
97 return template(context = {
98 value: 5.69
99 }).should.equal(6);
100 });
101 });
102 });
103
104}).call(this);