Skip to content

Commit

Permalink
ic: new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorybesson committed Jul 16, 2017
1 parent 69e1217 commit 231799d
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion tests/unit/core/utils/file.js
Expand Up @@ -10,12 +10,45 @@ import {
coreUtils,
abeExtend,
cmsData,
config
config,
Manager
} from '../../../../src/cli'

config.set({root: path.join(process.cwd(), 'tests', 'unit', 'fixtures')})

describe('coreUtils.file', function() {

before( function(done) {
Manager.instance.init()
.then(function () {
this.fixture = {
articleJsoninline: fse.readFileSync(path.join(process.cwd(), 'tests', 'unit', 'fixtures', 'themes', 'default', 'templates', 'article-data-jsoninline.html'), 'utf8')
}
done()

}.bind(this))
});

/**
* coreUtils.file.addFolder
*
*/
it('coreUtils.file.changePath()', function() {
var pathOrigin = '/post/test.html'
var change = 'newpost'
var result = coreUtils.file.changePath(pathOrigin, change)
chai.expect(result).to.be.a('string')
chai.expect(result.replace(config.root, '')).to.equal('/newpost/test.html')
});

it('cmsData.source.getContent()', function(done) {
var filePath = path.join(process.cwd(), 'tests', 'unit', 'fixtures', 'themes', 'default', 'templates', 'article-data-jsoninline.html')
var result = coreUtils.file.getContent(filePath)
console.log(result)
chai.expect(result).to.be.equal(this.fixture.articleJsoninline)
done()
});

/**
* coreUtils.file.addFolder
*
Expand Down

0 comments on commit 231799d

Please sign in to comment.