Skip to content

Commit

Permalink
Improving tests for URLStore
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabriskie committed Jul 22, 2014
1 parent 9343278 commit 8d14c29
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion specs/URLStore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,53 @@ 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');
});
});

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);
});
});

0 comments on commit 8d14c29

Please sign in to comment.