|
1
|
|
|
var chai = require('chai'); |
|
2
|
|
|
var path = require('path'); |
|
3
|
|
|
|
|
4
|
|
|
var config = require('../src/cli').config |
|
5
|
|
|
config.set({root: __dirname + '/fixtures/'}) |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
var cmsOperations = require('../src/cli').cmsOperations |
|
8
|
|
|
var Manager = require('../src/cli').Manager; |
|
9
|
|
|
var fse = require('fs-extra'); |
|
10
|
|
|
|
|
11
|
|
|
describe('Create', function() { |
|
12
|
|
|
before( function(done) { |
|
13
|
|
|
Manager.instance.init() |
|
14
|
|
|
.then(function () { |
|
15
|
|
|
Manager.instance._whereKeys = ['title', 'priority', 'abe_meta', 'articles'] |
|
16
|
|
|
Manager.instance.updateList() |
|
17
|
|
|
|
|
18
|
|
|
this.fixture = { |
|
19
|
|
|
tag: fse.readFileSync(__dirname + '/fixtures/templates/article.html', 'utf8'), |
|
|
|
|
|
|
20
|
|
|
jsonArticle: fse.readJsonSync(__dirname + '/fixtures/data/article-1.json'), |
|
|
|
|
|
|
21
|
|
|
jsonHomepage: fse.readJsonSync(__dirname + '/fixtures/data/homepage-1.json') |
|
|
|
|
|
|
22
|
|
|
} |
|
23
|
|
|
done() |
|
24
|
|
|
|
|
25
|
|
|
}.bind(this)) |
|
26
|
|
|
}); |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Util.getAllAttributes |
|
30
|
|
|
* |
|
31
|
|
|
*/ |
|
32
|
|
|
it('cmsOperations.create()', function(done) { |
|
33
|
|
|
cmsOperations.create('article', '', 'article-2.html', {query: ''}, this.fixture.jsonArticle, false) |
|
34
|
|
|
.then(function(resSave) { |
|
35
|
|
|
var html = path.join(config.root, config.draft.url, resSave.abe_meta.latest.abeUrl) |
|
36
|
|
|
var json = path.join(config.root, config.data.url, resSave.abe_meta.latest.abeUrl.replace('.html', '.json')) |
|
37
|
|
|
var stat = fse.statSync(html) |
|
38
|
|
|
if (stat) { |
|
39
|
|
|
chai.expect(stat).to.not.be.undefined; |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
stat = fse.statSync(json) |
|
42
|
|
|
if (stat) { |
|
43
|
|
|
chai.expect(stat).to.not.be.undefined; |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
fse.removeSync(html) |
|
46
|
|
|
fse.removeSync(json) |
|
47
|
|
|
done() |
|
48
|
|
|
}.bind(this)); |
|
|
|
|
|
|
49
|
|
|
}); |
|
50
|
|
|
}); |
|
51
|
|
|
|