Skip to content

Commit

Permalink
Add default middleware test
Browse files Browse the repository at this point in the history
  • Loading branch information
CKGrafico committed Dec 29, 2017
1 parent 501459c commit 0cf62e5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ You will need the following things properly installed on your computer.

* `npm test`

### Running Test Coverage

* `npm run cover`

### Building

* `npm run build` (production)
Expand Down
1 change: 0 additions & 1 deletion store/modules/generator/generator.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const helpers = {

let tmpImg = document.createElement('img');
tmpImg.onload = () => {
console.log(111111111111111111, tmpImg);
resolve({
width: tmpImg.width,
height: tmpImg.height
Expand Down
30 changes: 30 additions & 0 deletions test/middleware/default.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { expect } from 'test/libs/chai';

import defaultMiddleware from '~/middleware/default';

let paramsMockBuilder = (route: string) => ({
route: {
path: route
},
redirect: (path) => path
});

let params;

describe('default middleware', () => {

describe('when the middleware is loaded', () => {
it('should return if url is not generator', () => {
const route = '/test';
params = paramsMockBuilder(route);

expect(defaultMiddleware(params)).to.be.undefined;
});

it('should redirect to home if url is not generator', () => {
const route = '/generator';
params = paramsMockBuilder(route);
expect(defaultMiddleware(params)).to.be.equal('/');
});
});
});

0 comments on commit 0cf62e5

Please sign in to comment.