forked from bower/bower
-
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.
Upgrades handlebars to 4.0.5 to address bower#2195
Adds test for template util methods Upgrades handlebars Fixes RangeError due to `length` attribute in rpad helper
- Loading branch information
1 parent
1357f63
commit 6fff6fa
Showing
6 changed files
with
59 additions
and
10 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
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
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,53 @@ | ||
var expect = require('expect.js'); | ||
var template = require('../../lib/util/template'); | ||
var fs = require('fs'); | ||
|
||
describe('template: util template methods for templates in lib/templates', function () { | ||
describe('.render() - Renders a handlebars template', function () { | ||
var testTemplateName = 'test-template.tpl'; | ||
var testTemplatePath = __dirname + '/../../lib/templates/' + testTemplateName; | ||
beforeEach(function () { | ||
fs.writeFileSync(testTemplatePath, '{{foo}}'); | ||
console.log(); | ||
}); | ||
it('.render() returns a compiled test-template template', function () { | ||
var compiledStr = template.render( | ||
testTemplateName, | ||
{ foo: 'foo value' } | ||
); | ||
expect(compiledStr).to.be.equal( | ||
'foo value' | ||
); | ||
}); | ||
it('.render() throws when a non existent template is provided', function () { | ||
expect(function () { | ||
template.render( | ||
'test-template.not-present.tpl', | ||
{ foo: 'foo value' } | ||
); | ||
}).to.throwException(); | ||
}); | ||
afterEach(function () { | ||
fs.unlinkSync(testTemplatePath); | ||
}); | ||
}); | ||
|
||
describe('.exists() - Checks existence of a template', function () { | ||
var testTemplateName = 'test-template.tpl'; | ||
var testTemplatePath = __dirname + '/../../lib/templates/' + testTemplateName; | ||
beforeEach(function () { | ||
fs.writeFileSync(testTemplatePath, '{{foo}}'); | ||
}); | ||
it('.exists() returns true for an existing template', function () { | ||
var templateExists = template.exists(testTemplateName); | ||
expect(templateExists).to.be.ok(); | ||
}); | ||
it('.exists() returns false for a non existing template', function () { | ||
var templateExists = template.exists('test-template.not-present.tpl'); | ||
expect(templateExists).to.not.be.ok(); | ||
}); | ||
afterEach(function () { | ||
fs.unlinkSync(testTemplatePath); | ||
}); | ||
}); | ||
}); |