-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nicolaslabbe
committed
Dec 16, 2016
1 parent
15fbb47
commit 31781a6
Showing
6 changed files
with
114 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
var chai = require('chai'); | ||
var sinonChai = require('sinon-chai') | ||
var expect = chai.expect | ||
chai.use(sinonChai) | ||
var sinon = require('sinon'); | ||
var path = require('path'); | ||
var fse = require('fs-extra'); | ||
|
||
var config = require('../../../src/cli').config | ||
config.set({root: path.join(process.cwd(), 'test', 'fixtures')}) | ||
|
||
var cmsData = require('../../../src/cli').cmsData; | ||
var Manager = require('../../../src/cli').Manager; | ||
|
||
describe('Source', function() { | ||
before( function(done) { | ||
Manager.instance.init() | ||
.then(function () { | ||
this.fixture = { | ||
articleJsoninline: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-data-jsoninline.html'), 'utf8'), | ||
articleArrayinline: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-data-arrayinline.html'), 'utf8') | ||
} | ||
done() | ||
|
||
}.bind(this)) | ||
}); | ||
|
||
/** | ||
* | ||
* | ||
*/ | ||
it('cmsData.source.valueList', function(done) { | ||
var obj = {key:'titles'} | ||
var json = {abe_source:{}} | ||
cmsData.source.valueList(obj, this.fixture.articleJsoninline, json) | ||
.then(() => { | ||
chai.expect(json.abe_source.titles.length).to.be.equal(3); | ||
chai.expect(json.abe_source.titles[0].title).to.be.equal("rouge"); | ||
|
||
|
||
obj = {key:'titles'} | ||
json = {abe_source:{}} | ||
cmsData.source.valueList(obj, this.fixture.articleArrayinline, json) | ||
.then(() => { | ||
chai.expect(json.abe_source.titles.length).to.be.equal(3); | ||
done() | ||
}) | ||
}) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
var chai = require('chai'); | ||
var sinonChai = require('sinon-chai') | ||
var expect = chai.expect | ||
chai.use(sinonChai) | ||
var sinon = require('sinon'); | ||
var path = require('path'); | ||
var fse = require('fs-extra'); | ||
|
||
var config = require('../../../src/cli').config | ||
config.set({root: path.join(process.cwd(), 'test', 'fixtures')}) | ||
|
||
var cmsData = require('../../../src/cli').cmsData; | ||
var Manager = require('../../../src/cli').Manager; | ||
|
||
describe('Sql', function() { | ||
before( function(done) { | ||
Manager.instance.init() | ||
.then(function () { | ||
this.fixture = { | ||
articleJsoninline: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-data-jsoninline.html'), 'utf8'), | ||
articleArrayinline: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-data-arrayinline.html'), 'utf8') | ||
} | ||
done() | ||
|
||
}.bind(this)) | ||
}); | ||
|
||
/** | ||
* | ||
* | ||
*/ | ||
it('cmsData.sql.getDataSource', function() { | ||
var obj = {key:'titles'} | ||
var json = {abe_source:{}} | ||
var jsonString = cmsData.sql.getDataSource(this.fixture.articleJsoninline) | ||
chai.expect(jsonString.indexOf('rouge')).to.be.above(-1); | ||
JSON.parse(jsonString) | ||
jsonString = cmsData.sql.getDataSource(this.fixture.articleArrayinline) | ||
chai.expect(jsonString.indexOf('rouge')).to.be.above(-1); | ||
JSON.parse(jsonString) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{abe type='data' key='titles' desc='select titles' source='["rouge", "vert", "blue"]'}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{abe type='data' key='titles' desc='select titles' source='[{"title": "rouge", "id": 1},{"title": "vert", "id": 2},{"title": "blue", "id": 3}]' display="{{title}}"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters