File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,38 @@ var tape = require('tape');
4
4
5
5
var instructions = require ( '../index' ) ;
6
6
7
+ tape . test ( 'v5 tokenize' , function ( assert ) {
8
+ var v5Instructions = instructions ( 'v5' ) ;
9
+
10
+ var tokenString = 'Can {first} {second}' ;
11
+
12
+ var hasBoth = v5Instructions . tokenize ( tokenString , {
13
+ first : 'osrm' ,
14
+ second : 'do routing'
15
+ } , 'en' ) ;
16
+ assert . equal ( hasBoth , 'Can osrm do routing' , 'does find and replace' ) ;
17
+
18
+ var hasFirst = v5Instructions . tokenize ( tokenString , {
19
+ first : 'osrm' ,
20
+ second : ''
21
+ } , 'en' ) ;
22
+ assert . equal ( hasFirst , 'Can osrm ' , 'does find and replace and does not drop trailing spaces' ) ;
23
+
24
+ var hasSecond = v5Instructions . tokenize ( tokenString , {
25
+ second : 'swim' ,
26
+ first : ''
27
+ } , 'en' ) ;
28
+ assert . equal ( hasSecond , 'Can swim' , 'does find and replace and drops internal extra spaces' ) ;
29
+
30
+ var missingSecond = v5Instructions . tokenize ( tokenString , {
31
+ first : 'osrm'
32
+ } , 'en' ) ;
33
+ assert . equal ( missingSecond , 'Can osrm {second}' , 'does not replace tokens which are not provided' ) ;
34
+
35
+
36
+ assert . end ( ) ;
37
+ } ) ;
38
+
7
39
tape . test ( 'v5 directionFromDegree' , function ( assert ) {
8
40
var v5Instructions = instructions ( 'v5' ) ;
9
41
You can’t perform that action at this time.
0 commit comments