Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lexer.spec.js #170

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions dev/tests/spec/lexer.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//for node
var crossroads = crossroads || require('../../../dist/crossroads');
let crossroads = crossroads || require('../../../dist/crossroads');
//end node


Expand All @@ -9,7 +9,7 @@ describe('patternLexer', function(){
describe('getParamIds()', function(){

it('should return an Array with the ids', function(){
var ids = crossroads.patternLexer.getParamIds('/lorem/{ipsum}/{dolor}');
let ids = crossroads.patternLexer.getParamIds('/lorem/{ipsum}/{dolor}');
expect( ids[0] ).toEqual( 'ipsum' );
expect( ids[1] ).toEqual( 'dolor' );
});
Expand All @@ -21,25 +21,25 @@ describe('patternLexer', function(){
describe('compilePattern()', function(){

it('should create RegExp from string which should match pattern', function(){
var pattern = '/lorem/{ipsum}/{dolor}',
let pattern = '/lorem/{ipsum}/{dolor}',
regex = crossroads.patternLexer.compilePattern(pattern);
expect( regex.test(pattern) ).toEqual( true );
});

it('should work with special chars', function(){
var pattern = '/lo[rem](ipsum)/{ipsum}/{dolor}',
let pattern = '/lo[rem](ipsum)/{ipsum}/{dolor}',
regex = crossroads.patternLexer.compilePattern(pattern);
expect( regex.test(pattern) ).toEqual( true );
});

it('should work with optional params', function(){
var pattern = '/lo[rem](ipsum)/{ipsum}/{dolor}:foo::bar:/:blah:/maecennas',
let pattern = '/lo[rem](ipsum)/{ipsum}/{dolor}:foo::bar:/:blah:/maecennas',
regex = crossroads.patternLexer.compilePattern(pattern);
expect( regex.test(pattern) ).toEqual( true );
});

it('should support rest params', function(){
var pattern = '/lo[rem](ipsum)/{ipsum*}/{dolor}:foo::bar*:/:blah:/maecennas',
let pattern = '/lo[rem](ipsum)/{ipsum*}/{dolor}:foo::bar*:/:blah:/maecennas',
regex = crossroads.patternLexer.compilePattern(pattern);
expect( regex.test(pattern) ).toEqual( true );
});
Expand All @@ -50,7 +50,7 @@ describe('patternLexer', function(){
describe('getParamValues()', function(){

it('should return pattern params', function(){
var pattern = '/lorem/{ipsum}/{dolor}',
let pattern = '/lorem/{ipsum}/{dolor}',
regex = crossroads.patternLexer.compilePattern(pattern),
params = crossroads.patternLexer.getParamValues('/lorem/foo/bar', regex);

Expand Down