Skip to content

Commit 8498efa

Browse files
author
Katochimoto
committed
сохранение в истории страницы после возврата на предыдущую
1 parent a8a40d3 commit 8498efa

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/ns.page.history.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@
3737
// user pressed back button in browser
3838
if (prevPage === url) {
3939
nsHistory._history.pop();
40-
41-
} else {
42-
nsHistory._history.push(nsHistory._current);
4340
}
41+
42+
nsHistory._history.push(nsHistory._current);
4443
}
4544
}
4645

test/spec/ns.page.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
describe('ns.page', function() {
22

3+
beforeEach(function() {
4+
this.sinon.stub(ns.page.history, '_current', null);
5+
this.sinon.stub(ns.page.history, '_history', []);
6+
});
7+
38
describe('ns.page.go', function() {
49

510
describe('redirect', function() {
@@ -226,6 +231,28 @@ describe('ns.page', function() {
226231
});
227232
});
228233

234+
describe('ns.page.history.push', function() {
235+
beforeEach(function() {
236+
this.sinon.stub(ns, 'Update', function() {
237+
return {
238+
start: function() {
239+
return Vow.fulfill();
240+
}
241+
};
242+
});
243+
});
244+
245+
it('Должен запомнить страницу после возврата на предыдущую', function() {
246+
return ns.page.go('/inbox').then(function() {
247+
return ns.page.go('/message/1').then(function() {
248+
return ns.page.go('/inbox').then(function() {
249+
expect(ns.page.history.getPrevious()).to.be.eql('/message/1');
250+
});
251+
});
252+
});
253+
});
254+
});
255+
229256
});
230257

231258
});

0 commit comments

Comments
 (0)