/
registry-domain-register-templates.js
72 lines (63 loc) · 2.49 KB
/
registry-domain-register-templates.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
62
63
64
65
66
67
68
69
70
71
72
'use strict';
const expect = require('chai').expect;
const injectr = require('injectr');
const sinon = require('sinon');
describe('registry : domain : register-templates', () => {
const registerTemplates = require('../../src/registry/domain/register-templates.js');
describe('when templates get registered without additional templates', () => {
const registerd = registerTemplates();
it('should correctly register core-templates', () => {
expect(registerd.templatesHash).to.deep.eql({
'oc-template-es6': require('oc-template-es6'),
'oc-template-jade': require('oc-template-jade'),
'oc-template-handlebars': require('oc-template-handlebars')
});
expect(registerd.templatesInfo).to.deep.eql([
require('oc-template-es6').getInfo(),
require('oc-template-jade').getInfo(),
require('oc-template-handlebars').getInfo()
]);
});
});
describe('when templates get registered with additional templates', () => {
const templateMock = {
getInfo() {
return {
type: 'new-tpl',
version: '6.6.6',
externals: {}
};
}
};
const registerd = registerTemplates([templateMock]);
it('should correctly register core-templates & extra templates', () => {
expect(registerd.templatesHash).to.deep.eql({
'oc-template-es6': require('oc-template-es6'),
'oc-template-jade': require('oc-template-jade'),
'oc-template-handlebars': require('oc-template-handlebars'),
'new-tpl': templateMock
});
expect(registerd.templatesInfo).to.deep.eql([
require('oc-template-es6').getInfo(),
require('oc-template-jade').getInfo(),
require('oc-template-handlebars').getInfo(),
templateMock.getInfo()
]);
});
describe('and additional template is already part of core-templates', () => {
const registered = registerTemplates([require('oc-template-jade')]);
it('should correctly register core-templates only', () => {
expect(registered.templatesHash).to.deep.eql({
'oc-template-es6': require('oc-template-es6'),
'oc-template-jade': require('oc-template-jade'),
'oc-template-handlebars': require('oc-template-handlebars')
});
expect(registered.templatesInfo).to.deep.eql([
require('oc-template-es6').getInfo(),
require('oc-template-jade').getInfo(),
require('oc-template-handlebars').getInfo()
]);
});
});
});
});