27 lines
936 B
JavaScript
27 lines
936 B
JavaScript
const { isTabRoute, openStaticRoute } = require('../utils/static-ux/route-map')
|
|
|
|
describe('static ux navigation', () => {
|
|
test('recognizes tab routes by page path', () => {
|
|
expect(isTabRoute('/pages/home/index')).toBe(true)
|
|
expect(isTabRoute('/pages/home/index?from=portal')).toBe(true)
|
|
expect(isTabRoute('/packages/tcm/pages/assets/index?kind=history')).toBe(false)
|
|
})
|
|
|
|
test('uses switchTab for tab routes and navigateTo for non-tab routes', () => {
|
|
const wxApi = {
|
|
switchTab: jest.fn(),
|
|
navigateTo: jest.fn()
|
|
}
|
|
|
|
expect(openStaticRoute('/pages/library/index', wxApi)).toBe(true)
|
|
expect(openStaticRoute('/packages/tcm/pages/assets/index?kind=history', wxApi)).toBe(true)
|
|
|
|
expect(wxApi.switchTab).toHaveBeenCalledWith({
|
|
url: '/pages/library/index'
|
|
})
|
|
expect(wxApi.navigateTo).toHaveBeenCalledWith({
|
|
url: '/packages/tcm/pages/assets/index?kind=history'
|
|
})
|
|
})
|
|
})
|