Skip to content

Commit

Permalink
refactoring: UT fileattr
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Oct 5, 2016
1 parent ba793da commit 4bc6dd6
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/file-attr.js
@@ -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 test/fixtures/data/article-1-abe-d20160919T125255138Z.json
@@ -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"
}

0 comments on commit 4bc6dd6

Please sign in to comment.