fix(core): update
This commit is contained in:
@ -1,17 +1,17 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartrouter from '../ts/index';
|
||||
|
||||
let testrouter: smartrouter.SmartRouter;
|
||||
|
||||
tap.test('first test', async () => {
|
||||
testrouter = new smartrouter.SmartRouter({});
|
||||
expect(testrouter).to.be.instanceOf(smartrouter.SmartRouter);
|
||||
expect(testrouter).toBeInstanceOf(smartrouter.SmartRouter);
|
||||
});
|
||||
|
||||
tap.test('should handle a route change', async (toolsArg) => {
|
||||
const done = toolsArg.defer();
|
||||
testrouter.on('/myawesomeroute/:any', async (routeInfoArg) => {
|
||||
expect(routeInfoArg.params.any).to.equal('hello');
|
||||
expect(routeInfoArg.params.any).toEqual('hello');
|
||||
done.resolve();
|
||||
});
|
||||
testrouter.pushUrl('/myawesomeroute/hello');
|
||||
@ -21,26 +21,26 @@ tap.test('should handle a route change', async (toolsArg) => {
|
||||
tap.test('should handle a route change', async (toolsArg) => {
|
||||
const done = toolsArg.defer();
|
||||
testrouter.on('/myawesomeroute2/:wow', async (routeInfoArg) => {
|
||||
expect(routeInfoArg.params.wow).to.equal('hello2');
|
||||
expect(routeInfoArg.params.wow).toEqual('hello2');
|
||||
done.resolve();
|
||||
});
|
||||
testrouter.pushUrl('/myawesomeroute2/hello2');
|
||||
await done.promise;
|
||||
expect(window.location.href).to.equal('http://localhost:3007/myawesomeroute2/hello2');
|
||||
expect(window.location.href).toEqual('http://localhost:3007/myawesomeroute2/hello2');
|
||||
});
|
||||
|
||||
tap.test('should find a query param', async (toolsArg) => {
|
||||
const done = toolsArg.defer();
|
||||
testrouter.on('/myawesomeroute2/:wow', async (routeInfoArg) => {
|
||||
expect(routeInfoArg.params.wow).to.equal('hello2');
|
||||
expect(routeInfoArg.queryParams.aparam).to.equal('Yes');
|
||||
expect(routeInfoArg.params.wow).toEqual('hello2');
|
||||
expect(routeInfoArg.queryParams.aparam).toEqual('Yes');
|
||||
console.log('Here is what queryParams looks like');
|
||||
console.log(JSON.stringify(routeInfoArg.queryParams));
|
||||
done.resolve();
|
||||
});
|
||||
testrouter.pushUrl('/myawesomeroute2/hello2?aparam=Yes');
|
||||
await done.promise;
|
||||
expect(window.location.href).to.equal('http://localhost:3007/myawesomeroute2/hello2?aparam=Yes');
|
||||
expect(window.location.href).toEqual('http://localhost:3007/myawesomeroute2/hello2?aparam=Yes');
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
Reference in New Issue
Block a user