mirror of
/repos/Prototyper.git
synced 2025-12-30 06:31:32 +01:00
first test
This commit is contained in:
parent
e1c0b27948
commit
82f47bb27c
@ -6,7 +6,7 @@ module.exports = function (markers) {
|
||||
function replace(text, marker, getReplacement, once) {
|
||||
var deferred = when.defer();
|
||||
var regExp = new RegExp(markers.prefix + marker + markers.postfix, 'gmi');
|
||||
var matches = text.match(regExp);
|
||||
var matches = text && text.match && text.match(regExp);
|
||||
if (matches) {
|
||||
if (once) {
|
||||
matches = [matches[0]];
|
||||
|
||||
@ -252,7 +252,7 @@ module.exports = function (config, mongoDataInstance, helpers, markers) {
|
||||
|
||||
return {
|
||||
getPreviewHTML: getPreviewHTML,
|
||||
_replaceMarkers: replaceMarkers
|
||||
_replaceMarkers: replaceMarkers
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
29
test/test.helpers.js
Normal file
29
test/test.helpers.js
Normal file
@ -0,0 +1,29 @@
|
||||
var helpers = require('../helpers.js');
|
||||
var expect = require('chai').expect;
|
||||
var when = require('when');
|
||||
|
||||
|
||||
describe('Helpers', function () {
|
||||
var marker_prefix = '<!--\\s*@@';
|
||||
var marker_postfix = '\\s*-->';
|
||||
var helper = helpers({
|
||||
prefix: marker_prefix,
|
||||
postfix: marker_postfix
|
||||
});
|
||||
|
||||
describe('replace', function (done) {
|
||||
it('', function () {
|
||||
var promise = helper.replace(null, null, null, true);
|
||||
expect(promise).to.be.an('object');
|
||||
when(promise).then(
|
||||
function onSuccess(result) {
|
||||
expect(result).to.be.an('object');
|
||||
expect(result).to.be.empty();
|
||||
done();
|
||||
}, function onFailure(err) {
|
||||
done(err);
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user