Completed
Push — master ( 15fbb4...e26402 )
by greg
51s
created

test/cms/data/sql.js   A

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 42
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
B sql.js ➔ describe(ꞌSqlꞌ) 0 28 1
1
var chai = require('chai');
2
var sinonChai = require('sinon-chai')
3
var expect = chai.expect
4
chai.use(sinonChai)
5
var sinon = require('sinon');
6
var path = require('path');
7
var fse = require('fs-extra');
8
9
var config = require('../../../src/cli').config
10
config.set({root: path.join(process.cwd(), 'test', 'fixtures')})
11
12
var cmsData = require('../../../src/cli').cmsData;
13
var Manager = require('../../../src/cli').Manager;
14
15
describe('Sql', function() {
16
  before( function(done) {
17
    Manager.instance.init()
18
      .then(function () {
19
        this.fixture = {
20
          articleJsoninline: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-data-jsoninline.html'), 'utf8'),
21
          articleArrayinline: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-data-arrayinline.html'), 'utf8')
22
        }
23
        done()
24
        
25
      }.bind(this))
26
  });
27
28
  /**
29
   * 
30
   * 
31
   */
32
  it('cmsData.sql.getDataSource', function() {
33
    var obj = {key:'titles'}
0 ignored issues
show
Unused Code introduced by
The variable obj seems to be never used. Consider removing it.
Loading history...
34
    var json = {abe_source:{}}
0 ignored issues
show
Unused Code introduced by
The variable json seems to be never used. Consider removing it.
Loading history...
35
    var jsonString = cmsData.sql.getDataSource(this.fixture.articleJsoninline)
36
    chai.expect(jsonString.indexOf('rouge')).to.be.above(-1);
37
    JSON.parse(jsonString)
38
    jsonString = cmsData.sql.getDataSource(this.fixture.articleArrayinline)
39
    chai.expect(jsonString.indexOf('rouge')).to.be.above(-1);
40
    JSON.parse(jsonString)
41
  });
42
});
43