ray-template/__test__/basic/equalRouterPath.spec.ts
XiaoDaiGua-Ray 403fdd589a feat!: rebuild Ray Template as a monorepo
Share workspace packages between Ray Admin and the interactive docs.

BREAKING CHANGE: v6 is a new major line. v5 stays on legacy/v5.
2026-11-04 14:01:28 +08:00

24 lines
637 B
TypeScript

import { equalRouterPath } from '../../apps/admin/src/utils/basic'
describe('equalRouterPath', () => {
it('compare paths with parameters', () => {
const p1 = '/a?b=1'
const p2 = '/a?b=2'
expect(equalRouterPath(p1, p2)).toBe(true)
})
it('compare paths', () => {
const p1 = '/a'
const p2 = '/a/'
expect(equalRouterPath(p1, p2)).toBe(true)
})
})
it('ignores query, hash and trailing slashes and handles an empty route', () => {
expect(equalRouterPath('/items///?q=1#row', '/items#header')).toBe(true)
expect(equalRouterPath('', '?')).toBe(true)
expect(equalRouterPath('/a', '/aa')).toBe(false)
})