Skip to content
Open
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
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