Skip to content

Commit

Permalink
Root node backup is wrong #37 (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
TitanNano committed Feb 2, 2021
1 parent b0bdc6f commit adac75c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .travis/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ describe('Router', () => {
expect(triggerTracker3).to.be.false;
expect(result.window.location.hash).to.be.equal('#!/home/pages/p1/info/edit/2/view');
});

it('should backup "/" if the internal path is "/root"', () => {
expect(vm.getContext().window.location.hash).to.be.equal('#!/home/pages/p1/info/edit/2/view');

triggerTracker[0] = triggerTracker[1] = triggerTracker[2] = triggerTracker3 = false;

vm.updateContext({ testResult: null, testContext: { path: '/' } });
const result = vm.runModule('./tests/Router/routeChanged');

expect(result.window.localStorage.store['af.router.backup']).to.be.equal('/');
});
});

describe('up', () => {
Expand Down
4 changes: 2 additions & 2 deletions lib/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ const Router = {
},

backupPath(currentPath) {
if (currentPath[1] === 'root') {
currentPath[1] = '';
if (currentPath[0] === 'root') {
currentPath[0] = '';
}

window.localStorage.setItem('af.router.backup', `/${currentPath.join('/')}`);
Expand Down

0 comments on commit adac75c

Please sign in to comment.