-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.test.js
61 lines (47 loc) · 1.92 KB
/
index.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
50
51
52
53
54
55
56
57
58
59
60
61
const { HtmlValidate } = require('html-validate')
const Handlebars = require("handlebars");
const index = require('./index')
const resume = require('./resume.json')
describe.skip('render function', () => {
test('given no parameter then throw TypeError', () => {
expect(() => index.render()).toThrowError(TypeError)
})
test('given invalid parameter then throw TypeError', () => {
expect(() => index.render({})).toThrowError(TypeError)
})
test('given valid parameter then return valid html', () => {
const validator = new HtmlValidate()
expect(validator.validateString(index.render(resume)).valid).toBe(true)
})
})
describe('Handlebars Tests', () => {
describe('date helpers', () => {
this.fields = {
startDate: "2013-12-01",
endDate: "2013-12-31",
};
test('MONTH_YEAR converts month as an integer into abbreviated English format', () => {
this.html = "{{MONTH_YEAR startDate}}";
var template = Handlebars.compile(this.html);
this.fields['startDate'] = "2013-12-05";
var result = template(this.fields);
expect(result).toEqual("Dec 2013");
})
test('IF_DATES_HAVE_SAME_MONTH_AND_YEAR is true when dates have the same month and year', () => {
this.html = "{{IF_DATES_HAVE_SAME_MONTH_AND_YEAR startDate endDate}}";
var template = Handlebars.compile(this.html);
this.fields['startDate'] = "2013-12-01";
this.fields['endDate'] = "2013-12-31";
var result = template(this.fields);
expect(result).toEqual("true");
})
test('IF_DATES_HAVE_SAME_MONTH_AND_YEAR is false when dates have mismatching month', () => {
this.html = "{{IF_DATES_HAVE_SAME_MONTH_AND_YEAR startDate endDate}}";
var template = Handlebars.compile(this.html);
this.fields['startDate'] = "2013-01-01";
this.fields['endDate'] = "2013-12-01";
var result = template(this.fields);
expect(result).toEqual("false");
})
})
})