2019-11-10 21:44:15 +01:00
|
|
|
/* eslint-env jest */
|
|
|
|
import { cleanAmpPath } from 'next/dist/next-server/server/utils'
|
|
|
|
|
|
|
|
// convenince function so tests can be alligned neatly
|
|
|
|
// and easy to eyeball
|
2019-11-11 04:24:53 +01:00
|
|
|
const check = (input, expected) => expect(cleanAmpPath(input)).toBe(expected)
|
2019-11-10 21:44:15 +01:00
|
|
|
|
|
|
|
describe('cleanAmpPath', () => {
|
|
|
|
it('should leave url unchanged when no apm parameter is present', () =>
|
2019-11-11 04:24:53 +01:00
|
|
|
check('/some/path?param=blah', '/some/path?param=blah'))
|
2019-11-10 21:44:15 +01:00
|
|
|
|
|
|
|
it('should handle amp as the only parameter', () =>
|
2019-11-11 04:24:53 +01:00
|
|
|
check('/some/path?amp=1', '/some/path'))
|
2019-11-10 21:44:15 +01:00
|
|
|
|
|
|
|
it('should handle amp as the first parameter', () =>
|
2019-11-11 04:24:53 +01:00
|
|
|
check('/some/path?amp=1&page=10', '/some/path?page=10'))
|
2019-11-10 21:44:15 +01:00
|
|
|
|
|
|
|
it('should handle amp as the middle parameter', () =>
|
2019-11-11 04:24:53 +01:00
|
|
|
check('/some/path?page=10&=1&last=here', '/some/path?page=10&last=here'))
|
2019-11-10 21:44:15 +01:00
|
|
|
|
|
|
|
it('should handle amp as the last parameter', () =>
|
2019-11-11 04:24:53 +01:00
|
|
|
check('/some/path?page=10&=1', '/some/path?page=10'))
|
2019-11-10 21:44:15 +01:00
|
|
|
})
|