|
@@ -18,19 +18,19 @@ describe('router', () => {
|
|
|
r.add('/hello')
|
|
|
r.add('/users/add')
|
|
|
r.add('/users/:id')
|
|
|
- r.match(new RouterURL('http:/localhost/hello'))
|
|
|
- expect(r.is('/hello')).toBe(true)
|
|
|
- expect(r.is('/xyz')).toBe(false)
|
|
|
- expect(r.is('/xyz', '/hello')).toBe(true)
|
|
|
- expect(r.not('/hello')).toBe(false)
|
|
|
- expect(r.not('/xyz')).toBe(true)
|
|
|
- expect(r.not('/xyz', '/hello')).toBe(false)
|
|
|
- r.match(new RouterURL('http:/localhost/users/add'))
|
|
|
- expect(r.is('/users/add')).toBe(true)
|
|
|
- expect(r.not('/users/:id')).toBe(true)
|
|
|
- r.match(new RouterURL('http:/localhost/users/123'))
|
|
|
- expect(r.not('/users/add')).toBe(true)
|
|
|
- expect(r.is('/users/:id')).toBe(true)
|
|
|
+ let url = new RouterURL('http:/localhost/hello')
|
|
|
+ expect(r.is(url, '/hello')).toBe(true)
|
|
|
+ expect(r.is(url, '/xyz')).toBe(false)
|
|
|
+ expect(r.is(url, '/xyz', '/hello')).toBe(true)
|
|
|
+ expect(r.not(url, '/hello')).toBe(false)
|
|
|
+ expect(r.not(url, '/xyz')).toBe(true)
|
|
|
+ expect(r.not(url, '/xyz', '/hello')).toBe(false)
|
|
|
+ url = new RouterURL('http:/localhost/users/add')
|
|
|
+ expect(r.is(url, '/users/add')).toBe(true)
|
|
|
+ expect(r.not(url, '/users/:id(\\d+)')).toBe(true)
|
|
|
+ url = new RouterURL('http:/localhost/users/123')
|
|
|
+ expect(r.not(url, '/users/add')).toBe(true)
|
|
|
+ expect(r.is(url, '/users/:id(\\d+)')).toBe(true)
|
|
|
expect(r.notfound(new RouterURL('http:/localhost/hello/world'))).toBe(true)
|
|
|
expect(r.notfound(new RouterURL('http:/localhost/hello'))).toBe(false)
|
|
|
})
|