Completed
Pull Request — master (#39)
by
unknown
02:00
created

test/editor.js   A

Complexity

Total Complexity 4
Complexity/F 1.33

Size

Lines of Code 51
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
B editor.js ➔ describe(ꞌEditorꞌ) 0 36 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 {config} from '../src/cli'
7
config.set({root: path.join(__dirname,'fixtures')})
8
9
import {
10
  cmsEditor,
11
  abeExtend
12
} from '../src/cli'
13
14
import data from './fixtures/editor/index'
15
16
describe('Editor', function() {
17
  
18
  /**
19
   * cmsData.fileAttr.test
20
   * 
21
   */
22
  it('cmsEditor.printInput()', function() {
23
    var val = data.text;
24
    this.sinon = sinon.sandbox.create();
25
    this.sinon.stub(abeExtend.hooks.instance, 'trigger', function(param, html){
26
      return (param === 'beforeEditorInput') ? val : html;
27
    })
28
29
    var result = cmsEditor.printInput(val)
30
    chai.expect(result).to.be.a('string')
31
    var value = result.match(/value="[a-zA-Z0-9-]*"/ig)[0]
32
    chai.expect(value).to.equal('value="val2"')
33
    var reload = result.match(/reload="[a-zA-Z0-9-]*"/ig)[0]
34
    chai.expect(reload).to.equal('reload="val3"')
35
    var tabIndex = result.match(/tabIndex="[a-zA-Z0-9-]*"/ig)[0]
36
    chai.expect(tabIndex).to.equal('tabIndex="val4"')
37
    var dataRequired = result.match(/data-required="[a-zA-Z0-9-]*"/ig)[0]
38
    chai.expect(dataRequired).to.equal('data-required="val5"')
39
    var dataDisplay = result.match(/data-display="[a-zA-Z0-9-]*"/ig)[0]
40
    chai.expect(dataDisplay).to.equal('data-display="val6"')
41
    var dataVisible = result.match(/data-visible="[a-zA-Z0-9-]*"/ig)[0]
42
    chai.expect(dataVisible).to.equal('data-visible="val7"')
43
    var dataAutocomplete = result.match(/data-autocomplete="[a-zA-Z0-9-]*"/ig)[0]
44
    chai.expect(dataAutocomplete).to.equal('data-autocomplete="val8"')
45
    var placeholder = result.match(/placeholder="[a-zA-Z0-9-]*"/ig)[0]
46
    chai.expect(placeholder).to.equal('placeholder="val9"')
47
48
    this.sinon.restore()
49
  });
50
51
});
52