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('lowercase', function() {
|
11 | return describe('{{lowercase string}}', function() {
|
12 | return it('should return the string in lowercase', function() {
|
13 | var source, template;
|
14 |
|
15 | source = '{{lowercase "BENDER SHOULD NOT BE ALLOWED ON TV"}}';
|
16 | template = Handlebars.compile(source);
|
17 | return template().should.equal('bender should not be allowed on tv');
|
18 | });
|
19 | });
|
20 | });
|
21 |
|
22 | describe('uppercase', function() {
|
23 | return describe('{{uppercase string}}', function() {
|
24 | return it('should return the string in uppercase', function() {
|
25 | var source, template;
|
26 |
|
27 | source = '{{uppercase "bender should not be allowed on tv"}}';
|
28 | template = Handlebars.compile(source);
|
29 | return template().should.equal('BENDER SHOULD NOT BE ALLOWED ON TV');
|
30 | });
|
31 | });
|
32 | });
|
33 |
|
34 | describe('capitalizeFirst', function() {
|
35 | return describe('{{capitalizeFirst string}}', function() {
|
36 | return it('should return the string with the first word capitalized.', function() {
|
37 | var source, template;
|
38 |
|
39 | source = '{{capitalizeFirst "bender should not be allowed on tv"}}';
|
40 | template = Handlebars.compile(source);
|
41 | return template().should.equal('Bender should not be allowed on tv');
|
42 | });
|
43 | });
|
44 | });
|
45 |
|
46 | describe('capitalizeEach', function() {
|
47 | return describe('{{capitalizeEach string}}', function() {
|
48 | return it('should return the string with the every word capitalized.', function() {
|
49 | var source, template;
|
50 |
|
51 | source = '{{capitalizeEach "bender should not bE allowed on tV"}}';
|
52 | template = Handlebars.compile(source);
|
53 | return template().should.equal('Bender Should Not BE Allowed On TV');
|
54 | });
|
55 | });
|
56 | });
|
57 |
|
58 | describe('titleize', function() {
|
59 | return describe('{{titleize string}}', function() {
|
60 | return it('should return the string in title case.', function() {
|
61 | var source, template;
|
62 |
|
63 | source = '{{titleize "Bender-should-Not-be-allowed_on_Tv"}}';
|
64 | template = Handlebars.compile(source);
|
65 | return template().should.equal('Bender Should Not Be Allowed On Tv');
|
66 | });
|
67 | });
|
68 | });
|
69 |
|
70 | describe('sentence', function() {
|
71 | return describe('{{sentence string}}', function() {
|
72 | return it('should capitalize the first word of each sentence in a string and convert the rest of the sentence to lowercase.', function() {
|
73 | var source, template;
|
74 |
|
75 | source = '{{sentence "bender should NOT be allowed on TV. fry SHOULD be allowed on TV."}}';
|
76 | template = Handlebars.compile(source);
|
77 | return template().should.equal('Bender should not be allowed on tv. Fry should be allowed on tv.');
|
78 | });
|
79 | });
|
80 | });
|
81 |
|
82 | describe('reverse', function() {
|
83 | return describe('{{reverse string}}', function() {
|
84 | return it('should return the string in reverse.', function() {
|
85 | var source, template;
|
86 |
|
87 | source = '{{reverse "bender should NOT be allowed on TV."}}';
|
88 | template = Handlebars.compile(source);
|
89 | return template().should.equal('.VT no dewolla eb TON dluohs redneb');
|
90 | });
|
91 | });
|
92 | });
|
93 |
|
94 | describe('truncate', function() {
|
95 | describe('{{truncate string 31}}', function() {
|
96 | return it('should return then string truncated by a specified length.', function() {
|
97 | var source, template;
|
98 |
|
99 | source = '{{truncate "Bender should not be allowed on tv." 31}}';
|
100 | template = Handlebars.compile(source);
|
101 | return template().should.equal('Bender should not be allowed on');
|
102 | });
|
103 | });
|
104 | return describe('{{truncate string 31 "..."}}', function() {
|
105 | return it('should return then string truncated by a specified length, providing a custom string to denote an omission.', function() {
|
106 | var source, template;
|
107 |
|
108 | source = '{{truncate "Bender should not be allowed on tv." 31 "..."}}';
|
109 | template = Handlebars.compile(source);
|
110 | return template().should.equal('Bender should not be allowed...');
|
111 | });
|
112 | });
|
113 | });
|
114 |
|
115 | describe('center', function() {
|
116 | return describe('{{center string}}', function() {
|
117 | return it('should return the string centered by using non-breaking spaces.', function() {
|
118 | var source, template;
|
119 |
|
120 | source = '{{center "Bender should not be allowed on tv." 2}}';
|
121 | template = Handlebars.compile(source);
|
122 | return template().should.equal('  Bender should not be allowed on tv.  ');
|
123 | });
|
124 | });
|
125 | });
|
126 |
|
127 | describe('newLineToBr', function() {
|
128 | return describe('{{newLineToBr string}}', function() {
|
129 | return it('should return the string with new line characters converted to <br>.', function() {
|
130 | var source, template;
|
131 |
|
132 | source = '{{{newLineToBr "Bender \n should \n not \n be allowed on tv."}}}';
|
133 | template = Handlebars.compile(source);
|
134 | return template().should.equal('Bender <br> should <br> not <br> be allowed on tv.');
|
135 | });
|
136 | });
|
137 | });
|
138 |
|
139 | }).call(this);
|