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('formatDate', function() {
|
11 | return describe('{{formatDate date format}}', function() {
|
12 | return it('should return the date formated into a string given a specified format.', function() {
|
13 | var context, source, template;
|
14 |
|
15 | source = '{{formatDate date "%F"}}';
|
16 | template = Handlebars.compile(source);
|
17 | context = {
|
18 | date: new Date('2/21/1992')
|
19 | };
|
20 | return template(context).should.equal('1992-02-21');
|
21 | });
|
22 | });
|
23 | });
|
24 |
|
25 | describe('now', function() {
|
26 | return describe('{{now}}', function() {
|
27 | return it('should return the current date.', function() {
|
28 | var date, source, template;
|
29 |
|
30 | date = new Date().getTime();
|
31 | source = '{{now}}';
|
32 | template = Handlebars.compile(source);
|
33 | return template().should.be.within(date - 10, date + 10);
|
34 | });
|
35 | });
|
36 | });
|
37 |
|
38 | describe('timeago', function() {
|
39 | return describe('{{timeago date}}', function() {
|
40 | return it('should return a human-readable time phrase from the given a date', function() {
|
41 | var context, source, template;
|
42 |
|
43 | source = '{{timeago date}}';
|
44 | template = Handlebars.compile(source);
|
45 | context = {
|
46 | date: new Date()
|
47 | };
|
48 | return template(context).should.equal('Just now');
|
49 | });
|
50 | });
|
51 | });
|
52 |
|
53 | }).call(this);
|