Completed
Push — master ( 2115c9...bdfcbe )
by
unknown
02:14
created

test/template.js   A

Complexity

Total Complexity 9
Complexity/F 1

Size

Lines of Code 72
Function Count 9

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 0
wmc 9
nc 1
mnd 0
bc 9
fnc 9
dl 0
loc 72
rs 10
bpm 1
cpm 1
noi 4
c 3
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A template.js ➔ describe(ꞌTemplateꞌ) 0 62 1
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
          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...
18
        }
19
        done()
20
        
21
      }.bind(this))
22
  });
23
24
  /**
25
   * getAbeImport
26
   * 
27
   */
28
  it('cmsTemplate.template.getAbeImport()', function() {
29
    var res = cmsTemplate.template.getAbeImport(this.fixture.template)
30
    chai.expect(res).to.have.length(4);
31
  });
32
33
  /**
34
   * includePartials
35
   * 
36
   */
37
  it('cmsTemplate.template.includePartials()', function() {
38
    var template = cmsTemplate.template.includePartials(this.fixture.template)
39
    chai.expect(template).to.contain("{{abe type='text' key='title' desc='titre' tab='default'}}");
40
  });
41
42
  /**
43
   * cmsTemplate.template.getTemplate
44
   * 
45
   */
46
  it('cmsTemplate.template.getTemplate()', function() {
47
    var template = cmsTemplate.template.getTemplate('article')
48
    chai.expect(template).to.contain("{{abe type='text' key='title' desc='titre' tab='default' order='1'}}");
49
  });
50
51
  /**
52
   * getTemplate
53
   * 
54
   */
55
  it('cmsTemplate.template.getSelectTemplateKeys()', function() {
56
    const pathTemplate = path.join(config.root, config.templates.url)
57
    cmsTemplate.template.getSelectTemplateKeys(pathTemplate)
58
      .then((whereKeys) => {
59
        chai.expect(whereKeys.indexOf('abe_meta.date')).to.be.above(-1);
60
      })
61
  });
62
63
  /**
64
   * getTemplate
65
   * 
66
   */
67
  it('cmsTemplate.template.execRequestColumns()', function() { // templateKeys
68
    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...
69
    var ar = cmsTemplate.template.execRequestColumns(this.fixture.templateKeys)
70
    chai.expect(ar.indexOf('abe_meta.date')).to.be.above(-1);
71
  });
72
});
73