Skip to content

Commit

Permalink
add some tests for index.tokenize
Browse files Browse the repository at this point in the history
  • Loading branch information
mcwhittemore committed Sep 6, 2017
1 parent cfb2890 commit 4e96c31
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@ var tape = require('tape');

var instructions = require('../index');

tape.test('v5 tokenize', function(assert) {
var v5Instructions = instructions('v5');

var tokenString = 'Can {first} {second}';

var hasBoth = v5Instructions.tokenize(tokenString, {
first: 'osrm',
second: 'do routing'
}, 'en');
assert.equal(hasBoth, 'Can osrm do routing', 'does find and replace');

var hasFirst = v5Instructions.tokenize(tokenString, {
first: 'osrm',
second: ''
}, 'en');
assert.equal(hasFirst, 'Can osrm ', 'does find and replace and does not drop trailing spaces');

var hasSecond = v5Instructions.tokenize(tokenString, {
second: 'swim',
first: ''
}, 'en');
assert.equal(hasSecond, 'Can swim', 'does find and replace and drops internal extra spaces');

var missingSecond = v5Instructions.tokenize(tokenString, {
first: 'osrm'
}, 'en');
assert.equal(missingSecond, 'Can osrm {second}', 'does not replace tokens which are not provided');


assert.end();
});

tape.test('v5 directionFromDegree', function(assert) {
var v5Instructions = instructions('v5');

Expand Down

0 comments on commit 4e96c31

Please sign in to comment.