-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
49 lines (40 loc) · 1.47 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
42
43
44
45
46
47
48
49
/**
* helper-year <https://github.com/jonschlinkert/helper-year>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT license.
*/
'use strict';
var should = require('should');
var handlebars = require('handlebars');
var _ = require('lodash');
var year = require('./');
describe('year helper', function () {
var links = year();
it('should return the current year:', function() {
year().should.equal('2014');
});
it('should return the 2-digit current year when YY is passed:', function() {
year('YY').should.equal('14');
});
it('should return the 4-digit current year when YYYY is passed:', function() {
year('YYYY').should.equal('2014');
});
it('should return the 4-digit current year when yyyy is passed:', function() {
year('yyyy').should.equal('2014');
});
it('should work as a lodash helper:', function () {
_.template('<%= year() %>', {}, {imports: {year: year}}).should.eql(year());
_.template('<%= year("yy") %>', {}, {imports: {year: year}}).should.eql(year("yy"));
});
it('should work as a lodash mixin:', function () {
_.mixin({year: year});
_.template('<%= _.year() %>', {}).should.eql(year());
_.template('<%= _.year("yy") %>', {}).should.eql(year("yy"));
});
it('should work as a handlebars helper:', function () {
handlebars.registerHelper('year', year);
handlebars.compile('{{year}}')().should.eql(year());
handlebars.compile('{{year "yy"}}')().should.eql(year("yy"));
});
});