From 8d14c2954991a3f0d6d7dd76d9b85ee7f8431787 Mon Sep 17 00:00:00 2001 From: Matt Zabriskie Date: Tue, 22 Jul 2014 02:09:44 -0600 Subject: [PATCH] Improving tests for URLStore --- specs/URLStore.spec.js | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/specs/URLStore.spec.js b/specs/URLStore.spec.js index 8f079fa25a..ce6a5c0a5b 100644 --- a/specs/URLStore.spec.js +++ b/specs/URLStore.spec.js @@ -6,6 +6,10 @@ describe('when a new path is pushed to the URL', function () { URLStore.push('/a/b/c'); }); + afterEach(function () { + URLStore.teardown(); + }); + it('has the correct path', function () { expect(URLStore.getCurrentPath()).toEqual('/a/b/c'); }); @@ -13,10 +17,42 @@ describe('when a new path is pushed to the URL', function () { describe('when a new path is used to replace the URL', function () { beforeEach(function () { - URLStore.push('/a/b/c'); + URLStore.replace('/a/b/c'); + }); + + afterEach(function () { + URLStore.teardown(); }); it('has the correct path', function () { expect(URLStore.getCurrentPath()).toEqual('/a/b/c'); }); }); + +describe('when going back in history', function () { + afterEach(function () { + URLStore.teardown(); + }); + + it('has the correct path', function () { + URLStore.push('/a/b/c'); + expect(URLStore.getCurrentPath()).toEqual('/a/b/c'); + + URLStore.push('/d/e/f'); + expect(URLStore.getCurrentPath()).toEqual('/d/e/f'); + + URLStore.back(); + expect(URLStore.getCurrentPath()).toEqual('/a/b/c'); + }); + + it('should not go back before recorded history', function () { + var error = false; + try { + URLStore.back(); + } catch (e) { + error = true; + } + + expect(error).toEqual(true); + }); +});