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

template.js ➔ describe(ꞌTemplateꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 62

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
nc 1
dl 0
loc 62
rs 9.4743
c 2
b 0
f 0
nop 0

6 Functions

Rating   Name   Duplication   Size   Complexity  
A template.js ➔ ... ➔ it(ꞌcmsTemplate.template.includePartials()ꞌ) 0 4 1
A template.js ➔ ... ➔ it(ꞌcmsTemplate.template.getAbeImport()ꞌ) 0 4 1
A template.js ➔ ... ➔ it(ꞌcmsTemplate.template.getSelectTemplateKeys()ꞌ) 0 7 1
A template.js ➔ ... ➔ before 0 11 1
A template.js ➔ ... ➔ it(ꞌcmsTemplate.template.getTemplate()ꞌ) 0 4 1
A template.js ➔ ... ➔ it(ꞌcmsTemplate.template.execRequestColumns()ꞌ) 0 5 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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