From 8498efa64ad3dc1dea69c2cd32d8c83d33d474fe Mon Sep 17 00:00:00 2001 From: Katochimoto Date: Thu, 7 May 2015 12:00:52 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B2=20=D0=B8=D1=81=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D0=B8=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B?= =?UTF-8?q?=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20=D0=B2=D0=BE=D0=B7=D0=B2?= =?UTF-8?q?=D1=80=D0=B0=D1=82=D0=B0=20=D0=BD=D0=B0=20=D0=BF=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D1=8B=D0=B4=D1=83=D1=89=D1=83=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ns.page.history.js | 5 ++--- test/spec/ns.page.js | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/ns.page.history.js b/src/ns.page.history.js index 5a1c6a03..ed596d37 100644 --- a/src/ns.page.history.js +++ b/src/ns.page.history.js @@ -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); } } diff --git a/test/spec/ns.page.js b/test/spec/ns.page.js index e8d56429..4826926b 100644 --- a/test/spec/ns.page.js +++ b/test/spec/ns.page.js @@ -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() { @@ -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'); + }); + }); + }); + }); + }); + }); });