moy-router
Version:
Give a solution for moy-dom router management.
24 lines (20 loc) • 890 B
JavaScript
import { Maybe } from 'moy-fp'
import getLocation from 'src/utils/getLocation'
describe('test for getLocation', () => {
test('getLocation when window just has a pathname', () => {
history.replaceState(undefined, '', '/murakami')
expect(getLocation()).toEqual(Maybe.of('/murakami'))
})
test('getLocation when window has pathname and search', () => {
history.replaceState(undefined, '', '/murakami?a=1&b=2')
expect(getLocation()).toEqual(Maybe.of('/murakami?a=1&b=2'))
})
test('getLocation when window has pathname and hash', () => {
history.replaceState(undefined, '', '/murakami#a')
expect(getLocation()).toEqual(Maybe.of('/murakami#a'))
})
test('getLocation when window has pathname, search and hash', () => {
history.replaceState(undefined, '', '/murakami?a=1&b=2#a')
expect(getLocation()).toEqual(Maybe.of('/murakami?a=1&b=2#a'))
})
})