Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverJAsh committed Jan 23, 2019
1 parent 11bde7a commit 4a8985b
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 101 deletions.
16 changes: 2 additions & 14 deletions modules/__tests__/BrowserHistory-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,11 @@ describe('a browser history', () => {
});

describe('push with an encoded path string', () => {
it('creates a location object with decoded pathname', done => {
it('creates a location object with encoded pathname', done => {
TestSequences.PushEncodedLocation(history, done);
});
});

describe('push with an invalid path string (bad percent-encoding)', () => {
it('throws an error', done => {
TestSequences.PushInvalidPathname(history, done);
});
});

describe('replace a new path', () => {
it('calls change listeners with the new location', done => {
TestSequences.ReplaceNewLocation(history, done);
Expand All @@ -93,15 +87,9 @@ describe('a browser history', () => {
});
});

describe('replace with an invalid path string (bad percent-encoding)', () => {
it('throws an error', done => {
TestSequences.ReplaceInvalidPathname(history, done);
});
});

describe('location created by encoded and unencoded pathname', () => {
it('produces the same location.pathname', done => {
TestSequences.LocationPathnameAlwaysDecoded(history, done);
TestSequences.LocationPathnameAlwaysSame(history, done);
});
});

Expand Down
16 changes: 2 additions & 14 deletions modules/__tests__/HashHistory-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,11 @@ describe('a hash history', () => {
});

describe('push with an encoded path string', () => {
it('creates a location object with decoded pathname', done => {
it('creates a location object with encoded pathname', done => {
TestSequences.PushEncodedLocation(history, done);
});
});

describe('push with an invalid path string (bad percent-encoding)', () => {
it('throws an error', done => {
TestSequences.PushInvalidPathname(history, done);
});
});

describe('replace a new path', () => {
it('calls change listeners with the new location', done => {
TestSequences.ReplaceNewLocation(history, done);
Expand All @@ -96,15 +90,9 @@ describe('a hash history', () => {
});
});

describe('replace with an invalid path string (bad percent-encoding)', () => {
it('throws an error', done => {
TestSequences.ReplaceInvalidPathname(history, done);
});
});

describe('location created by encoded and unencoded pathname', () => {
it('produces the same location.pathname', done => {
TestSequences.LocationPathnameAlwaysDecoded(history, done);
TestSequences.LocationPathnameAlwaysSame(history, done);
});
});

Expand Down
18 changes: 0 additions & 18 deletions modules/__tests__/LocationUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,6 @@ describe('createLocation', () => {
});
});

describe('with a path that cannot be decoded', () => {
describe('given as a string', () => {
it('throws custom message when decodeURI throws a URIError', () => {
expect(() => {
createLocation('/test%');
}).toThrow('Pathname "/test%" could not be decoded.');
});
});

describe('given as an object', () => {
it('throws custom message when decodeURI throws a URIError', () => {
expect(() => {
createLocation({ pathname: '/test%' });
}).toThrow('Pathname "/test%" could not be decoded.');
});
});
});

describe('key', () => {
it('has a key property if a key is provided', () => {
const location = createLocation('/the/path', undefined, 'key');
Expand Down
16 changes: 2 additions & 14 deletions modules/__tests__/MemoryHistory-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,11 @@ describe('a memory history', () => {
});

describe('push with an encoded path string', () => {
it('creates a location object with decoded pathname', done => {
it('creates a location object with encoded pathname', done => {
TestSequences.PushEncodedLocation(history, done);
});
});

describe('push with an invalid path string (bad percent-encoding)', () => {
it('throws an error', done => {
TestSequences.PushInvalidPathname(history, done);
});
});

describe('replace a new path', () => {
it('calls change listeners with the new location', done => {
TestSequences.ReplaceNewLocation(history, done);
Expand All @@ -87,15 +81,9 @@ describe('a memory history', () => {
});
});

describe('replace with an invalid path string (bad percent-encoding)', () => {
it('throws an error', done => {
TestSequences.ReplaceInvalidPathname(history, done);
});
});

describe('location created by encoded and unencoded pathname', () => {
it('produces the same location.pathname', done => {
TestSequences.LocationPathnameAlwaysDecoded(history, done);
TestSequences.LocationPathnameAlwaysSame(history, done);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function(history, done) {
},
location => {
expect(location).toMatchObject({
pathname: '/歴史'
pathname: '/%E6%AD%B4%E5%8F%B2'
});

// encoded object
Expand All @@ -20,7 +20,7 @@ export default function(history, done) {
},
location => {
expect(location).toMatchObject({
pathname: '/歴史'
pathname: '/%E6%AD%B4%E5%8F%B2'
});
// unencoded string
const pathname = '/歴史';
Expand Down
2 changes: 1 addition & 1 deletion modules/__tests__/TestSequences/PushEncodedLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function(history, done) {
(location, action) => {
expect(action).toBe('PUSH');
expect(location).toMatchObject({
pathname: '/歴史',
pathname: '/%E6%AD%B4%E5%8F%B2',
search: '?%E3%82%AD%E3%83%BC=%E5%80%A4',
hash: '#%E3%83%8F%E3%83%83%E3%82%B7%E3%83%A5'
});
Expand Down
17 changes: 0 additions & 17 deletions modules/__tests__/TestSequences/PushInvalidPathname.js

This file was deleted.

17 changes: 0 additions & 17 deletions modules/__tests__/TestSequences/ReplaceInvalidPathname.js

This file was deleted.

6 changes: 2 additions & 4 deletions modules/__tests__/TestSequences/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ export { default as InitialLocationNoKey } from './InitialLocationNoKey';
export { default as InitialLocationHasKey } from './InitialLocationHasKey';
export { default as Listen } from './Listen';
export {
default as LocationPathnameAlwaysDecoded
} from './LocationPathnameAlwaysDecoded';
default as LocationPathnameAlwaysSame
} from './LocationPathnameAlwaysSame';
export { default as NoslashHashPathCoding } from './NoslashHashPathCoding';
export { default as PushEncodedLocation } from './PushEncodedLocation';
export { default as PushInvalidPathname } from './PushInvalidPathname';
export { default as PushNewLocation } from './PushNewLocation';
export { default as PushMissingPathname } from './PushMissingPathname';
export { default as PushSamePath } from './PushSamePath';
Expand All @@ -34,7 +33,6 @@ export { default as PushState } from './PushState';
export { default as PushStateWarning } from './PushStateWarning';
export { default as PushRelativePathname } from './PushRelativePathname';
export { default as PushUnicodeLocation } from './PushUnicodeLocation';
export { default as ReplaceInvalidPathname } from './ReplaceInvalidPathname';
export { default as ReplaceNewLocation } from './ReplaceNewLocation';
export { default as ReplaceSamePath } from './ReplaceSamePath';
export { default as ReplaceState } from './ReplaceState';
Expand Down

0 comments on commit 4a8985b

Please sign in to comment.