Completed
Push — master ( 880c09...d1844c )
by
unknown
02:09
created

e.insertDebugtoolUtilities()ꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 4
rs 10
nop 0
1
var chai = require('chai');
2
var path = require('path');
3
4
var config = require('../src/cli').config
5
config.set({root: __dirname + '/fixtures'})
0 ignored issues
show
Compatibility introduced by
Consider using the path module for constructing paths since they are otherwise not cross-OS compatible.
Loading history...
6
7
var cmsTemplate = require('../src/cli').cmsTemplate;
8
var Manager = require('../src/cli').Manager;
9
var fse = require('fs-extra');
10
11
describe('Template', function() {
12
  before( function(done) {
13
    Manager.instance.init()
14
      .then(function () {
15
        this.fixture = {
16
          template: fse.readFileSync(__dirname + '/fixtures/templates/article.html', 'utf-8'),
0 ignored issues
show
Compatibility introduced by
Consider using the path module for constructing paths since they are otherwise not cross-OS compatible.
Loading history...
17
          articleEach: fse.readFileSync(__dirname + '/fixtures/templates/article-each-abe.html', 'utf-8'),
0 ignored issues
show
Compatibility introduced by
Consider using the path module for constructing paths since they are otherwise not cross-OS compatible.
Loading history...
18
          templateKeys: fse.readFileSync(__dirname + '/fixtures/templates/article-keys.html', 'utf-8')
0 ignored issues
show
Compatibility introduced by
Consider using the path module for constructing paths since they are otherwise not cross-OS compatible.
Loading history...
19
        }
20
        done()
21
        
22
      }.bind(this))
23
  });
24
25
  /**
26
   * getAbeImport
27
   * 
28
   */
29
  it('cmsTemplate.template.getAbeImport()', function() {
30
    var res = cmsTemplate.template.getAbeImport(this.fixture.template)
31
    chai.expect(res).to.have.length(4);
32
  });
33
34
  /**
35
   * includePartials
36
   * 
37
   */
38
  it('cmsTemplate.template.includePartials()', function() {
39
    var template = cmsTemplate.template.includePartials(this.fixture.template)
40
    chai.expect(template).to.contain("{{abe type='text' key='title' desc='titre' tab='default'}}");
41
  });
42
43
  /**
44
   * cmsTemplate.template.getTemplate
45
   * 
46
   */
47
  it('cmsTemplate.template.getTemplate()', function() {
48
    var template = cmsTemplate.template.getTemplate('article')
49
    chai.expect(template).to.contain("{{abe type='text' key='title' desc='titre' tab='default' order='1'}}");
50
  });
51
52
  /**
53
   * getTemplate
54
   * 
55
   */
56
  it('cmsTemplate.template.getSelectTemplateKeys()', function() {
57
    const pathTemplate = path.join(config.root, config.templates.url)
58
    cmsTemplate.template.getSelectTemplateKeys(pathTemplate)
59
      .then((whereKeys) => {
60
        chai.expect(whereKeys.indexOf('abe_meta.date')).to.be.above(-1);
61
      })
62
  });
63
64
  /**
65
   * getTemplate
66
   * 
67
   */
68
  it('cmsTemplate.template.execRequestColumns()', function() { // templateKeys
69
    const pathTemplate = path.join(config.root, config.templates.url)
0 ignored issues
show
Unused Code introduced by
The constant pathTemplate seems to be never used. Consider removing it.
Loading history...
70
    var ar = cmsTemplate.template.execRequestColumns(this.fixture.templateKeys)
71
    chai.expect(ar.indexOf('abe_meta.date')).to.be.above(-1);
72
  });
73
74
  /**
75
   * cmsTemplate.insertDebugtoolUtilities
76
   * 
77
   */
78
  it('cmsTemplate.insertDebugtoolUtilities()', function() {
79
    var txt = cmsTemplate.insertDebugtoolUtilities('</body>');
80
    chai.expect(txt.length).to.above(10);
81
  });
82
83
  /**
84
   * cmsTemplate.encodeAbeTagAsComment
85
   * 
86
   */
87
  it('cmsTemplate.encodeAbeTagAsComment()', function() {
88
    var txt = cmsTemplate.encodeAbeTagAsComment(this.fixture.articleEach);
89
    chai.expect(txt.indexOf('{')).to.equal(-1);
90
  });
91
});
92