Skip to content

Commit 8d14c29

Browse files
committed
Improving tests for URLStore
1 parent 9343278 commit 8d14c29

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

specs/URLStore.spec.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,53 @@ describe('when a new path is pushed to the URL', function () {
66
URLStore.push('/a/b/c');
77
});
88

9+
afterEach(function () {
10+
URLStore.teardown();
11+
});
12+
913
it('has the correct path', function () {
1014
expect(URLStore.getCurrentPath()).toEqual('/a/b/c');
1115
});
1216
});
1317

1418
describe('when a new path is used to replace the URL', function () {
1519
beforeEach(function () {
16-
URLStore.push('/a/b/c');
20+
URLStore.replace('/a/b/c');
21+
});
22+
23+
afterEach(function () {
24+
URLStore.teardown();
1725
});
1826

1927
it('has the correct path', function () {
2028
expect(URLStore.getCurrentPath()).toEqual('/a/b/c');
2129
});
2230
});
31+
32+
describe('when going back in history', function () {
33+
afterEach(function () {
34+
URLStore.teardown();
35+
});
36+
37+
it('has the correct path', function () {
38+
URLStore.push('/a/b/c');
39+
expect(URLStore.getCurrentPath()).toEqual('/a/b/c');
40+
41+
URLStore.push('/d/e/f');
42+
expect(URLStore.getCurrentPath()).toEqual('/d/e/f');
43+
44+
URLStore.back();
45+
expect(URLStore.getCurrentPath()).toEqual('/a/b/c');
46+
});
47+
48+
it('should not go back before recorded history', function () {
49+
var error = false;
50+
try {
51+
URLStore.back();
52+
} catch (e) {
53+
error = true;
54+
}
55+
56+
expect(error).toEqual(true);
57+
});
58+
});

0 commit comments

Comments
 (0)