|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -var path = require('path'); |
4 | | -var pkg = require('../package.json'); |
5 | | -var RouteNode = require(path.join(__dirname, '..', pkg.main)); |
6 | | -var should = require('should'); |
7 | | -var omit = require('lodash.omit'); |
| 3 | +import path from 'path'; |
| 4 | +import pkg from '../package.json'; |
| 5 | +import RouteNode from '../modules/RouteNode'; |
| 6 | +import should from 'should'; |
| 7 | +import omit from 'lodash.omit'; |
8 | 8 |
|
9 | 9 | function withoutMeta(obj) { |
10 | 10 | return omit(obj, '_meta'); |
11 | 11 | } |
12 | 12 |
|
13 | | -require('mocha'); |
14 | | - |
15 | 13 | describe('RouteNode', function () { |
16 | 14 | it('should instanciate an empty RouteNode if no routes are specified in constructor', function () { |
17 | 15 | var node = new RouteNode(); |
@@ -329,10 +327,35 @@ describe('RouteNode', function () { |
329 | 327 | var node = new RouteNode('', '?a', [ |
330 | 328 | new RouteNode('route', '/path?b') |
331 | 329 | ]); |
332 | | - withoutMeta(node.matchPath('/path?a=1&b=2')).should.eql({ |
| 330 | + node.matchPath('/path?a=1&b=2').should.eql({ |
| 331 | + _meta: { |
| 332 | + '': { a: 'query' }, |
| 333 | + 'route': { b: 'query' } |
| 334 | + }, |
333 | 335 | name: 'route', |
334 | 336 | params: { a: '1', b: '2' } |
335 | 337 | }); |
| 338 | + |
| 339 | + node.buildState('route', { b: '1' }).should.eql({ |
| 340 | + _meta: { |
| 341 | + '': { a: 'query' }, |
| 342 | + 'route': { b: 'query' } |
| 343 | + }, |
| 344 | + name: 'route', |
| 345 | + params: { b: '1' } |
| 346 | + }); |
| 347 | + |
| 348 | + node.buildState('route', { a: '1', b: '1' }).should.eql({ |
| 349 | + _meta: { |
| 350 | + '': { a: 'query' }, |
| 351 | + 'route': { b: 'query' } |
| 352 | + }, |
| 353 | + name: 'route', |
| 354 | + params: { a: '1', b: '1' } |
| 355 | + }); |
| 356 | + |
| 357 | + node.buildPath('route', { b: '2' }).should.equal('/path?b=2'); |
| 358 | + node.buildPath('route', { a: '1', b: '2' }).should.equal('/path?a=1&b=2'); |
336 | 359 | }); |
337 | 360 | }); |
338 | 361 |
|
|
0 commit comments