Skip to content

Commit

Permalink
Merge pull request remix-run#100 from mzabriskie/master
Browse files Browse the repository at this point in the history
Improving tests for URLStore
  • Loading branch information
mjackson committed Jul 22, 2014
2 parents 9343278 + 8d14c29 commit 444f438
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 444f438

Please sign in to comment.