Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade babel-eslint #45

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/navigo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/navigo.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/navigo.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/navigo.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "navigo",
"version": "2.3.0",
"version": "2.3.1",
"description": "A simple vanilla JavaScript router with a fallback for older browsers",
"main": "lib/navigo.js",
"jsnext:main": "src/index.js",
Expand Down Expand Up @@ -30,7 +30,7 @@
"devDependencies": {
"babel": "6.3.26",
"babel-core": "6.4.5",
"babel-eslint": "5.0.0-beta6",
"babel-eslint": "^6.1.2",
"babel-loader": "6.2.1",
"babel-plugin-add-module-exports": "0.1.2",
"babel-preset-es2015": "6.3.13",
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Navigo.prototype = {
handler(m.params);
return m;
} else if (this._defaultHandler && (url === '' || url === '/')) {
this._lastRouteResolved = url;
this._defaultHandler();
return true;
} else if (this._notFoundHandler) {
Expand Down
25 changes: 24 additions & 1 deletion test/Navigo.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ describe('Given an instance of Navigo', function () {
expect(action).to.be.equal('save');
done();
};

router.on(/users\/(\d+)\/(\w+)\/?/, handler);
router.resolve('site.com/app/users/42/save');
});
Expand All @@ -118,6 +119,7 @@ describe('Given an instance of Navigo', function () {
describe('and when we use the destroy method', function () {
it('should not be able to resolve a route', function () {
var handler = sinon.spy();

router.on('/users', handler);
router.resolve('site.com/app/users');
router.destroy();
Expand Down Expand Up @@ -245,7 +247,7 @@ describe('Given an instance of Navigo', function () {

expect(handler)
.to.be.calledOnce
.and.to.be.calledWith({ productId: '42' })
.and.to.be.calledWith({ productId: '42' });
});
});
});
Expand All @@ -271,4 +273,25 @@ describe('Given an instance of Navigo', function () {
});
});

describe('Given the issue #41 case', function () {
it('should resolve routes properly', function () {
var taskRoute = sinon.spy();
var defaultRoute = sinon.spy();

router = new Navigo('http://site.com/', true);
router.on('/task/:taskId/', taskRoute);
router.on(defaultRoute);

router.resolve('/task/frontend-1');
router.resolve('/');
router.resolve('/task/frontend-1');

expect(defaultRoute).to.be.calledOnce;
expect(taskRoute).to.be.calledTwice;
expect(taskRoute.firstCall).to.be.calledWith({ taskId: 'frontend-1' });
expect(taskRoute.secondCall).to.be.calledWith({ taskId: 'frontend-1' });

});
});

});