Completed
Push — master ( 4d0225...c0c74f )
by greg
01:48
created

test/core/manager/Manager.js   A

Complexity

Total Complexity 10
Complexity/F 1

Size

Lines of Code 68
Function Count 10

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 68
rs 10
wmc 10
mnd 0
bc 10
fnc 10
bpm 1
cpm 1
noi 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A Manager.js ➔ describe(ꞌManagerꞌ) 0 56 1
1
var chai = require('chai');
2
var path = require('path');
3
4
var Manager = require('../../../src/cli').Manager
5
var config = require('../../../src/cli').config
6
var cmsOperations = require('../../../src/cli').cmsOperations
7
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...
8
9
var cmsData = require('../../../src/cli').cmsData;
10
var Manager = require('../../../src/cli').Manager;
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable Manager already seems to be declared on line 4. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
11
var fse = require('fs-extra');
12
13
describe('Manager', function() {
14
  before( function(done) {
15
    Manager.instance.init()
16
      .then(function () {
17
18
        this.fixture = {
19
          tag: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article.html'), 'utf8'),
20
          jsonArticle: fse.readJsonSync(path.join(process.cwd(), 'test', 'fixtures', 'files', 'article-4.json')),
21
          jsonArticle1: fse.readJsonSync(path.join(process.cwd(), 'test', 'fixtures', 'data', 'article-1.json'))
22
        }
23
        done()
24
        
25
      }.bind(this))
26
  });
27
28
  it('getStructureAndTemplates()', function() {
29
    const data = Manager.instance.getStructureAndTemplates()
30
    chai.assert.equal(data['templates'][0].name, 'article-data-arrayinline', 'failed !')
31
    chai.assert.equal(data['templates'].length, 25, 'failed !')
32
  });
33
34
  it('updateStructureAndTemplates()', function() {
35
    Manager.instance.updateStructureAndTemplates()
36
    const data = Manager.instance.getStructureAndTemplates()
37
    chai.assert.equal(data['templates'][0].name, 'article-data-arrayinline', 'failed !')
38
    chai.assert.equal(data['templates'].length, 25, 'failed !')
39
  });
40
41
  it('getList()', function() {
42
    const list = Manager.instance.getList()
43
    chai.assert.equal(list[0].name, 'article-1.json', 'failed !')
44
    chai.assert.equal(list.length, 3, 'failed !')
45
  });
46
47
  it('getListWithStatusOnFolder() status publish', function() {
48
    const list = Manager.instance.getListWithStatusOnFolder('publish')
49
    chai.assert.equal(list[0].name, 'article-1.json', 'failed !')
50
    chai.assert.equal(list.length, 2, 'failed !')
51
  });
52
53
  it('getListWithStatusOnFolder() status draft', function() {
54
    const list = Manager.instance.getListWithStatusOnFolder('draft')
55
    chai.assert.equal(list.length, 2, 'failed !')
56
  });
57
58
  it('getListWithStatusOnFolder() status review', function() {
59
    const list = Manager.instance.getListWithStatusOnFolder('review')
60
    chai.assert.equal(list.length, 0, 'failed !')
61
  });
62
63
  it('getListWithStatusOnFolder() status publish /0-1', function() {
64
    const list = Manager.instance.getListWithStatusOnFolder('draft', '0-1')
65
    chai.assert.equal(list[0].name, 'article-2.json', 'failed !')
66
    chai.assert.equal(list.length, 1, 'failed !')
67
  });
68
});
69