mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 21:11:14 +00:00
test(assistant): shared card tests, wiki rows and ratchets after the card packages
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
*
|
||||
* The links the chat opens the planner with while it is on screen: another
|
||||
* tab of the trip switches there and leaves the URL, and the parts' own links
|
||||
* (tours, bookings, road trip) take nothing yet.
|
||||
* (tours, bookings, road trip) are each handed the planner, the workspace and
|
||||
* the query (each part's own test covers what it does with them).
|
||||
*/
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import type { ReactNode } from 'react';
|
||||
@@ -12,6 +13,11 @@ import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { useAssistantEntityLinks } from './useAssistantEntityLinks';
|
||||
|
||||
const parts = vi.hoisted(() => ({ tour: vi.fn(), booking: vi.fn(), roadtrip: vi.fn() }));
|
||||
vi.mock('./deepLinks/useTourDeepLink', () => ({ useTourDeepLink: parts.tour }));
|
||||
vi.mock('./deepLinks/useBookingDeepLink', () => ({ useBookingDeepLink: parts.booking }));
|
||||
vi.mock('./deepLinks/useRoadtripDeepLink', () => ({ useRoadtripDeepLink: parts.roadtrip }));
|
||||
|
||||
type Options = Parameters<typeof useAssistantEntityLinks>[0];
|
||||
|
||||
function setup(path: string) {
|
||||
@@ -37,9 +43,14 @@ describe('useAssistantEntityLinks', () => {
|
||||
expect(hook.result.current.search).toBe('?expense=7');
|
||||
});
|
||||
|
||||
it("FE-PLANNER-ENTITYLINK-002: the parts' own links take nothing yet, and nothing switches without a tab", () => {
|
||||
it("FE-PLANNER-ENTITYLINK-002: each part's own link gets the planner, the workspace and the query; nothing switches without a tab", () => {
|
||||
const { planner, hook } = setup('/trips/5?tour=12');
|
||||
expect(planner.handleTabChange).not.toHaveBeenCalled();
|
||||
expect(hook.result.current.search).toBe('?tour=12');
|
||||
for (const part of [parts.tour, parts.booking, parts.roadtrip]) {
|
||||
const links = part.mock.lastCall?.[0] as { planner: unknown; searchParams: URLSearchParams };
|
||||
expect(links.planner).toBe(planner);
|
||||
expect(links.searchParams.get('tour')).toBe('12');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user