Completed
Push — master ( 5ac0c3...6da433 )
by greg
02:29
created

operations.js ➔ ... ➔ ???   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
c 1
b 1
f 0
nc 2
dl 0
loc 8
rs 9.4285
nop 1
1
var chai = require('chai');
2
var path = require('path');
3
4
var config = require('../src/cli').config
5
config.set({root: path.join(__dirname,'fixtures')})
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(path.join(__dirname, 'fixtures/templates/article.html'), 'utf8'),
20
          jsonArticle: fse.readJsonSync(path.join(__dirname, '/fixtures/files/article-4.json')),
21
          jsonHomepage: fse.readJsonSync(path.join(__dirname, '/fixtures/data/homepage-1.json'))
22
        }
23
        done()
24
        
25
      }.bind(this))
26
  });
27
28
  it('cmsOperations.create()', function(done) {
29
    cmsOperations.create('article', '', 'article-2.html', {query: ''}, this.fixture.jsonArticle, false)
30
      .then(function(resSave) {
31
        var json = path.join(config.root, config.data.url, resSave.abe_meta.latest.abeUrl.replace('.html', '.json'))
32
        console.log(json)
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
33
        var stat = fse.statSync(json)
34
        if (stat) {
35
          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...
36
        }
37
        fse.removeSync(json)
38
        done()
39
      }.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...
40
  });
41
42
  it('cmsOperations.duplicate()', function(done) {
43
    cmsOperations.duplicate('article-1.html', 'article', '', 'article-2.html', {}, false)
44
    .then(function(resSave) {
45
      var json = path.join(config.root, config.data.url, resSave.abe_meta.latest.abeUrl.replace('.html', '.json'))
46
      var stat = fse.statSync(json)
47
      if (stat) {
48
        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...
49
      }
50
      fse.removeSync(json)
51
      done()
52
    }.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...
53
  });
54
55
  it('cmsOperations.duplicate() update', function(done) {
56
    cmsOperations.duplicate('article-1.html', 'article', '', 'article-1.html', {}, true)
57
    .then(function(resSave) {
58
      var json = path.join(config.root, config.data.url, resSave.abe_meta.link.replace('.html', '.json'))
59
      var stat = fse.statSync(json)
60
      if (stat) {
61
        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...
62
      }
63
      done()
64
    }.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...
65
  });
66
});
67