Skip to content

Commit

Permalink
updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbrokke committed Feb 14, 2016
1 parent 9240677 commit 4dac3bd
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var assert = require('assert');
var _ = require('lodash');

var TokenReplacer = require('../index.js');

Expand All @@ -19,6 +20,34 @@ describe('TokenReplacer', function() {

assert.notEqual(tokenString, replacer.processString(tokenString));
});

it('should accept a custom evaluation function', function() {
var dummyConfigObject = {
customValue: 'ABC_123'
};

function customReplacerFn(s) {
var customEvaluation = s;

if (_.startsWith(s, 'dummyConfigObject')) {
var key = s.split('.')[1];

if (!!dummyConfigObject[key]) {
customEvaluation = dummyConfigObject[key];
}
}

return customEvaluation;
}

var options = {
customReplacerFn: customReplacerFn
};

var replacer = new TokenReplacer(options);

assert.equal(replacer.processString('<@dummyConfigObject.customValue@>'), dummyConfigObject.customValue);
});
});

describe('#processString()', function() {
Expand Down

0 comments on commit 4dac3bd

Please sign in to comment.