-
Notifications
You must be signed in to change notification settings - Fork 960
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize hash and search strings (#813)
- Loading branch information
Showing
2 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import expect from 'expect'; | ||
import { createPath } from 'history'; | ||
|
||
describe('createPath', () => { | ||
describe('given only a pathname', () => { | ||
it('returns the pathname unchanged', () => { | ||
let path = createPath({ pathname: 'https://google.com' }); | ||
expect(path).toBe('https://google.com'); | ||
}); | ||
}); | ||
|
||
describe('given a pathname and a search param', () => { | ||
it('returns the constructed pathname', () => { | ||
let path = createPath({ | ||
pathname: 'https://google.com', | ||
search: '?something=cool' | ||
}); | ||
expect(path).toBe('https://google.com?something=cool'); | ||
}); | ||
}); | ||
|
||
describe('given a pathname and a search param without ?', () => { | ||
it('returns the constructed pathname', () => { | ||
let path = createPath({ | ||
pathname: 'https://google.com', | ||
search: 'something=cool' | ||
}); | ||
expect(path).toBe('https://google.com?something=cool'); | ||
}); | ||
}); | ||
|
||
describe('given a pathname and a hash param', () => { | ||
it('returns the constructed pathname', () => { | ||
let path = createPath({ | ||
pathname: 'https://google.com', | ||
hash: '#section-1' | ||
}); | ||
expect(path).toBe('https://google.com#section-1'); | ||
}); | ||
}); | ||
|
||
describe('given a pathname and a hash param without #', () => { | ||
it('returns the constructed pathname', () => { | ||
let path = createPath({ | ||
pathname: 'https://google.com', | ||
hash: 'section-1' | ||
}); | ||
expect(path).toBe('https://google.com#section-1'); | ||
}); | ||
}); | ||
|
||
describe('given a full location object', () => { | ||
it('returns the constructed pathname', () => { | ||
let path = createPath({ | ||
pathname: 'https://google.com', | ||
search: 'something=cool', | ||
hash: '#section-1' | ||
}); | ||
expect(path).toBe('https://google.com?something=cool#section-1'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters