-
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
Nov 28, 2016
1 parent
083035c
commit 81bc0cc
Showing
13 changed files
with
1,103 additions
and
646 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,46 @@ | ||
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 cmsTemplates = require('../../../src/cli').cmsTemplates; | ||
var cmsData = require('../../../src/cli').cmsData; | ||
var Manager = require('../../../src/cli').Manager; | ||
|
||
describe('cmsTemplates', function() { | ||
before( function(done) { | ||
Manager.instance.init() | ||
.then(function () { | ||
this.fixture = { | ||
articleEach: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-each-abe.html'), 'utf-8') | ||
} | ||
done() | ||
|
||
}.bind(this)) | ||
}); | ||
|
||
/** | ||
* cmsTemplates.encodeAbeTagAsComment | ||
* | ||
*/ | ||
it('cmsTemplates.encodeAbeTagAsComment()', function() { | ||
// stub | ||
var sinonInstance = sinon.sandbox.create(); | ||
var validDataAbe = sinonInstance.stub(cmsData.regex, 'validDataAbe'); | ||
validDataAbe.returns('') | ||
|
||
// test | ||
var txt = cmsTemplates.encodeAbeTagAsComment(this.fixture.articleEach); | ||
chai.expect(txt.indexOf('{')).to.equal(-1); | ||
|
||
// unstub | ||
sinon.assert.calledOnce(cmsData.regex.validDataAbe) | ||
cmsData.regex.validDataAbe.restore() | ||
}); | ||
}); |
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,38 @@ | ||
var chai = require('chai'); | ||
var sinonChai = require('sinon-chai') | ||
var expect = chai.expect | ||
chai.use(sinonChai) | ||
var sinon = require('sinon'); | ||
var fs = require('fs-extra'); | ||
var mkdirp = require('mkdirp'); | ||
var path = require('path'); | ||
var bcrypt = require('bcrypt-nodejs'); | ||
var Cookies = require('cookies'); | ||
var jwt = require('jwt-simple'); | ||
var Handlebars =require('../../../../src/cli').Handlebars | ||
|
||
var coreUtils = require('../../../../src/cli').coreUtils | ||
var config = require('../../../../src/cli').config | ||
config.set({root: path.join(process.cwd(), 'test', 'fixtures')}) | ||
|
||
var User = require('../../../../src/cli').User; | ||
describe('Handlebars.helpers.isAuthorized', function() { | ||
before( function() { | ||
config.users.enable = true | ||
this.fixture = { | ||
htmlIsAuthorized: fs.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'isAuthorized.html'), 'utf8'), | ||
htmlIsAuthorizedTrue: fs.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'isAuthorizedTrue.html'), 'utf8'), | ||
users: JSON.parse(fs.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'users', 'users.json'), 'utf8')) | ||
} | ||
}); | ||
|
||
it('Handlebars.helpers.isAuthorized', function() { | ||
var template = Handlebars.compile(this.fixture.htmlIsAuthorized) | ||
var resHtml = template({}) | ||
chai.expect(resHtml).to.be.equal(""); | ||
|
||
template = Handlebars.compile(this.fixture.htmlIsAuthorizedTrue) | ||
resHtml = template({}) | ||
chai.expect(resHtml).to.not.be.equal(""); | ||
}); | ||
}); |
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,22 @@ | ||
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 config = require('../../../src/cli').config | ||
config.set({root: path.join(process.cwd(), 'test', 'fixtures')}) | ||
|
||
var cmsTemplates = require('../../../src/cli').cmsTemplates; | ||
|
||
describe('cmsTemplates', function() { | ||
/** | ||
* cmsTemplates.insertDebugtoolUtilities | ||
* | ||
*/ | ||
it('cmsTemplates.insertDebugtoolUtilities()', function() { | ||
var txt = cmsTemplates.insertDebugtoolUtilities('</body>', false); | ||
chai.expect(txt.length).to.above(10); | ||
}); | ||
}); |
Oops, something went wrong.