Completed
Push — master ( 02e9e0...81eefd )
by
unknown
02:06
created

operations.js ➔ describe(ꞌCreateꞌ)   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 40

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 40
rs 8.8571
nop 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A operations.js ➔ ... ➔ it(ꞌcmsOperations.create()ꞌ) 0 18 1
A operations.js ➔ ... ➔ before 0 15 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 cmsOperations = require('../src/cli').cmsOperations
8
var Manager = require('../src/cli').Manager;
9
var fse = require('fs-extra');
10
11
describe('Create', function() {
12
  before( function(done) {
13
    Manager.instance.init()
14
      .then(function () {
15
        Manager.instance._whereKeys = ['title', 'priority', 'abe_meta', 'articles']
16
        Manager.instance.updateList()
17
18
        this.fixture = {
19
          tag: fse.readFileSync(__dirname + '/fixtures/templates/article.html', 'utf8'),
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...
20
          jsonArticle: fse.readJsonSync(__dirname + '/fixtures/data/article-1.json'),
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...
21
          jsonHomepage: fse.readJsonSync(__dirname + '/fixtures/data/homepage-1.json')
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...
22
        }
23
        done()
24
        
25
      }.bind(this))
26
  });
27
28
  /**
29
   * Util.getAllAttributes
30
   * 
31
   */
32
  it('cmsOperations.create()', function(done) {
33
    cmsOperations.create('article', '', 'article-2.html', {query: ''}, this.fixture.jsonArticle, false)
34
      .then(function(resSave) {
35
        var html = path.join(config.root, config.draft.url, resSave.abe_meta.latest.abeUrl)
36
        var json = path.join(config.root, config.data.url, resSave.abe_meta.latest.abeUrl.replace('.html', '.json'))
37
        var stat = fse.statSync(html)
38
        if (stat) {
39
          chai.expect(stat).to.not.be.undefined;
0 ignored issues
show
introduced by
The result of the property access to chai.expect(stat).to.not.be.undefined is not used.
Loading history...
40
        }
41
        stat = fse.statSync(json)
42
        if (stat) {
43
          chai.expect(stat).to.not.be.undefined;
0 ignored issues
show
introduced by
The result of the property access to chai.expect(stat).to.not.be.undefined is not used.
Loading history...
44
        }
45
        fse.removeSync(html)
46
        fse.removeSync(json)
47
        done()
48
      }.bind(this));
0 ignored issues
show
unused-code introduced by
The call to bind does not seem necessary since the function does not use this. Consider calling it directly.
Loading history...
49
  });
50
});
51