Completed
Pull Request — master (#66)
by
unknown
02:44
created

test/cms/structure/structure.js   A

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 73
Function Count 4

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 73
rs 10
wmc 4
mnd 0
bc 4
fnc 4
bpm 1
cpm 1
noi 3

1 Function

Rating   Name   Duplication   Size   Complexity  
A structure.js ➔ describe(ꞌcmsStructureꞌ) 0 57 1
1
import chai from 'chai'
2
import path from 'path'
3
import sinonChai from'sinon-chai'
4
chai.use(sinonChai)
5
import sinon from 'sinon'
6
import execPromise from 'child-process-promise'
7
import mkdirp from 'mkdirp'
8
import events from 'events'
9
import {
10
  cmsStructure,
11
  abeExtend,
0 ignored issues
show
Unused Code introduced by
The variable abeExtend seems to be never used. Consider removing it.
Loading history...
12
  config
13
} from '../../../src/cli'
14
15
config.set({root: path.join(process.cwd(), 'test','fixtures')})
16
17
describe('cmsStructure', function() {
18
19
  var folderPath = '/my/folder/path'
20
  
21
  /**
22
   * cmsStructure.structure.addFolder
23
   * 
24
   */
25
  it('cmsStructure.structure.addFolder()', function() {
26
    this.sinon = sinon.sandbox.create();
27
    //TODO: find how to stub function litteral "mkdirp"
28
    // var stub = sinon.stub(mkdirp, "")
29
    // var stub = sinon.createStubInstance(mkdirp);
30
31
    // var result = cmsStructure.structure.addFolder(folderPath)
32
    // chai.expect(result).to.not.be.undefined
33
    // chai.expect(result).to.be.a('string')
34
    // chai.expect(result).to.equal(folderPath)
35
    // chai.expect(result).to.equal(path.join(config.root, config.publish.url, '/myImageFolder'))
36
    // sinon.assert.calledOnce(mkdirp)
37
    // mkdirp.restore()
38
  });
39
40
  /**
41
   * cmsStructure.structure.removeFolder
42
   * 
43
   */
44
  it('cmsStructure.structure.removeFolder()', function() {
45
    this.sinon = sinon.sandbox.create();
46
    var stub = sinon.stub(execPromise, "exec")
47
    stub.returns(Promise.resolve({
48
      'stdout': null,
49
      'stderr': null
50
    }));
51
    var result = cmsStructure.structure.removeFolder(folderPath)
52
    chai.expect(result).to.not.be.undefined
0 ignored issues
show
introduced by
The result of the property access to chai.expect(result).to.not.be.undefined is not used.
Loading history...
53
    chai.expect(result).to.equal(folderPath)
54
    sinon.assert.calledOnce(execPromise.exec)
55
    execPromise.exec.restore()
56
  });
57
58
  /**
59
   * cmsStructure.structure.editStructure
60
   * 
61
   */
62
  it('cmsStructure.structure.editStructure()', function() {
63
    this.sinon = sinon.sandbox.create();
64
    var stub = sinon.stub(cmsStructure.structure, "removeFolder")
65
    stub.returns('')
66
    var result = cmsStructure.structure.editStructure('remove', folderPath)
67
    chai.expect(result).to.not.be.undefined
0 ignored issues
show
introduced by
The result of the property access to chai.expect(result).to.not.be.undefined is not used.
Loading history...
68
    chai.expect(result).to.equal(folderPath)
69
    sinon.assert.calledOnce(cmsStructure.structure.removeFolder)
70
    cmsStructure.structure.removeFolder.restore()
71
  });
72
73
});
74