Skip to content

Commit

Permalink
сохранение в истории страницы после возврата на предыдущую
Browse files Browse the repository at this point in the history
  • Loading branch information
Katochimoto committed May 7, 2015
1 parent a8a40d3 commit 8498efa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/ns.page.history.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@
// user pressed back button in browser
if (prevPage === url) {
nsHistory._history.pop();

} else {
nsHistory._history.push(nsHistory._current);
}

nsHistory._history.push(nsHistory._current);
}
}

Expand Down
27 changes: 27 additions & 0 deletions test/spec/ns.page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
describe('ns.page', function() {

beforeEach(function() {
this.sinon.stub(ns.page.history, '_current', null);
this.sinon.stub(ns.page.history, '_history', []);
});

describe('ns.page.go', function() {

describe('redirect', function() {
Expand Down Expand Up @@ -226,6 +231,28 @@ describe('ns.page', function() {
});
});

describe('ns.page.history.push', function() {
beforeEach(function() {
this.sinon.stub(ns, 'Update', function() {
return {
start: function() {
return Vow.fulfill();
}
};
});
});

it('Должен запомнить страницу после возврата на предыдущую', function() {
return ns.page.go('/inbox').then(function() {
return ns.page.go('/message/1').then(function() {
return ns.page.go('/inbox').then(function() {
expect(ns.page.history.getPrevious()).to.be.eql('/message/1');
});
});
});
});
});

});

});
Expand Down

0 comments on commit 8498efa

Please sign in to comment.