Skip to content

Commit

Permalink
Роутер не добавляет дефолтный параметр
Browse files Browse the repository at this point in the history
  • Loading branch information
doochik committed Nov 18, 2015
1 parent 088782c commit 2a2aca1
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions test/spec/ns.router2.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,56 @@ describe('router: new route parsing method', function() {
});
});

describe('ns.router.generateUrl()', function() {
xdescribe('rebulus test', function() {

beforeEach(function() {
ns.router.regexps.TRebulus = '\\d+|any-items';

ns.router.routes = {
route: {
'/view/{param:TRebulus}': 'view',
'/journal/{startTimestamp:int=100}/{eventType:id=all-events}/{platform:id=all-plaforms}': 'view1'
}
};
ns.router.init();
});

it('1', function() {
var route1 = ns.router('/view/1');
console.log('/view/1', route1);

var route2 = ns.router('/view/any-items');
console.log('/view/any-items', route2);

var route3 = ns.router('/view/foo');
console.log('/view/foo', route3);

var route4 = ns.router('/view/5ny-items');
console.log('/view/5ny-items', route4);

var route5 = ns.router('/view/any-item');
console.log('/view/any-item', route5);
});

it('2', function() {
var route1 = ns.router('/journal/1');
console.log('/journal/1', route1);

var route2 = ns.router('/journal/1/');
console.log('/journal/1/', route2);

var route3 = ns.router.generateUrl('view1', {startTimestamp:2});
console.log('{startTimestamp:2} -> ', route3);

var route4 = ns.router.generateUrl('view1', {eventType: 'a'});
console.log('{eventType:1} -> ', route4);


});

});

describe.only('ns.router.generateUrl()', function() {
beforeEach(function() {
ns.router.regexps.any = '.+?';

Expand All @@ -193,7 +242,8 @@ describe('router: new route parsing method', function() {
'/{context==top}/image/{id:int}': 'view',
'/{context}/image/{id:int}': 'view',
'/test/{id}': 'test',
'/search/query={query:any}': 'encode'
'/search/query={query:any}': 'encode',
'/journal/{ts:int=100}/{type:id=any-type}': 'journal'
}
};
ns.router.init();
Expand Down Expand Up @@ -236,6 +286,12 @@ describe('router: new route parsing method', function() {
params: { context: 'new-context', id: 4 },
result: '/new-context/image/4'
},
{
name: 'generate route with default params',
id: 'journal',
params: { type: 'mytype' },
result: '/journal/100/mytype'
},
{
name: 'should encode only url values',
id: 'encode',
Expand Down

0 comments on commit 2a2aca1

Please sign in to comment.