Files
SpeedScope/src/lib/hash-params.test.ts
T
Jamie Wong 72c05fe6ba Backfill some more tests (#112)
* Add tests for getHashParams

* Add tests for Color

* Cover a few more lines
2018-08-01 11:42:55 -07:00

28 lines
1.0 KiB
TypeScript

import {getHashParams} from './hash-params'
test('getHashParams', () => {
expect(getHashParams('')).toEqual({})
expect(getHashParams('#')).toEqual({})
expect(getHashParams('#title=hello')).toEqual({title: 'hello'})
expect(getHashParams('#localProfilePath=file:///tmp/file.js')).toEqual({
localProfilePath: 'file:///tmp/file.js',
})
expect(
getHashParams(
'#profileURL=https://raw.githubusercontent.com/jlfwong/speedscope/master/sample/profiles/speedscope/0.1.2/simple-sampled.speedscope.json',
),
).toEqual({
profileURL:
'https://raw.githubusercontent.com/jlfwong/speedscope/master/sample/profiles/speedscope/0.1.2/simple-sampled.speedscope.json',
})
expect(getHashParams('#title=hello&localProfilePath=file:///tmp/file.js')).toEqual({
title: 'hello',
localProfilePath: 'file:///tmp/file.js',
})
expect(getHashParams('#title=hello%20world')).toEqual({
title: 'hello world',
})
expect(getHashParams('#abc=bcd')).toEqual({})
expect(getHashParams('garbage')).toEqual({})
})