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
Oct 5, 2016
1 parent
ba793da
commit 4bc6dd6
Showing
2 changed files
with
59 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var chai = require('chai'); | ||
|
||
var config = require('../src/cli').config | ||
config.set({root: __dirname + '/fixtures'}) | ||
|
||
var cmsData = require('../src/cli').cmsData; | ||
var Manager = require('../src/cli').Manager; | ||
var fse = require('fs-extra'); | ||
|
||
describe('fileAttr', function() { | ||
before( function(done) { | ||
Manager.instance.init() | ||
.then(function () { | ||
Manager.instance._whereKeys = ['title', 'priority', 'abe_meta', 'articles'] | ||
Manager.instance.updateList() | ||
|
||
this.fixture = { | ||
jsonDraft: fse.readJsonSync(__dirname + '/fixtures/data/article-1-abe-d20160919T125255138Z.json') | ||
} | ||
done() | ||
|
||
}.bind(this)) | ||
}); | ||
|
||
/** | ||
* cmsData.fileAttr.test | ||
* | ||
*/ | ||
it('cmsData.fileAttr.test()', function() { | ||
var bool = cmsData.fileAttr.test(this.fixture.jsonDraft.abe_meta.latest.abeUrl) | ||
chai.expect(bool).to.be.true; | ||
bool = cmsData.fileAttr.test(this.fixture.jsonDraft.abe_meta.link) | ||
chai.expect(bool).to.be.false; | ||
}); | ||
|
||
/** | ||
* cmsData.fileAttr.delete | ||
* | ||
*/ | ||
it('cmsData.fileAttr.delete()', function() { | ||
var str = cmsData.fileAttr.delete(this.fixture.jsonDraft.abe_meta.latest.abeUrl) | ||
var bool = cmsData.fileAttr.test(str) | ||
chai.expect(bool).to.be.false; | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
test/fixtures/data/article-1-abe-d20160919T125255138Z.json
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,14 @@ | ||
{ | ||
"abe_meta": { | ||
"template": "article", | ||
"link": "/article-1.json", | ||
"status": "draft", | ||
"date": "2016-07-19T12:52:55.138Z", | ||
"latest": { | ||
"date": "2016-07-19T12:52:55.138Z", | ||
"abeUrl": "/de/destinations/algeria/luxury-algiers-city-guide-abe-d20160919T125255138Z.shtml" | ||
} | ||
}, | ||
"priority":2, | ||
"title":"article" | ||
} |