@cccsaurora/howler-ui 3.1.0-dev.1679 → 3.1.0-dev.1690
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -71,13 +71,21 @@ describe('handlebars helpers', () => {
|
|
|
71
71
|
expect(String(helperMap.entries.callback?.(null, options))).toBe('Invalid Object.');
|
|
72
72
|
expect(helperMap.replace.callback?.('alpha beta', 'beta', 'gamma', options)).toBe('alpha gamma');
|
|
73
73
|
expect(() => helperMap.replace.callback?.('alpha', undefined, 'x', options)).toThrow('Replace expects three arguments');
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const mockFetch = vi.fn().mockResolvedValue(new Response(JSON.stringify({ nested: { value: 'cached' } }), {
|
|
75
|
+
headers: { 'Content-Type': 'application/json' }
|
|
76
76
|
}));
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const originalFetch = globalThis.fetch;
|
|
78
|
+
try {
|
|
79
|
+
globalThis.fetch = mockFetch;
|
|
80
|
+
await expect(helperMap.fetch.callback?.('https://example.com/data', 'nested.value', options)).resolves.toBe('cached');
|
|
81
|
+
await expect(helperMap.fetch.callback?.('https://example.com/data', 'nested.value', options)).resolves.toBe('cached');
|
|
82
|
+
await expect(helperMap.fetch.callback?.('https://example.com/data', 'missing.value', options)).resolves.toBeUndefined();
|
|
83
|
+
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
globalThis.fetch = originalFetch;
|
|
87
|
+
}
|
|
88
|
+
expect(globalThis.fetch).toBe(originalFetch);
|
|
81
89
|
});
|
|
82
90
|
it('renders component-backed helpers', () => {
|
|
83
91
|
mockExecuteFunction.mockReturnValue([]);
|
|
@@ -140,7 +140,7 @@ describe('AnalyticDetails', () => {
|
|
|
140
140
|
expect(screen.getByText('owner@example.com')).toBeInTheDocument();
|
|
141
141
|
expect(screen.getByText('avatar:user-2')).toBeInTheDocument();
|
|
142
142
|
expect(screen.getByText('overview-tab')).toBeInTheDocument();
|
|
143
|
-
expect(mockSearchUsers).toHaveBeenCalledWith('uname:"owner1"');
|
|
143
|
+
await waitFor(() => expect(mockSearchUsers).toHaveBeenCalledWith('uname:"owner1"'));
|
|
144
144
|
fireEvent.click(screen.getByText('switch-comments'));
|
|
145
145
|
await waitFor(() => expect(screen.getByText('comments-tab')).toBeInTheDocument());
|
|
146
146
|
fireEvent.click(screen.getByText('change-filter'));
|
package/package.json
CHANGED
package/tests/mocks.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
import type { useSearchParams } from 'react-router';
|
|
2
|
+
import { type Mock } from 'vitest';
|
|
3
|
+
type SearchParamsSetter = ReturnType<typeof useSearchParams>[1];
|
|
4
|
+
type ReactRouterMock = {
|
|
5
|
+
mockSearchParams: URLSearchParams;
|
|
6
|
+
mockSetParams: Mock<SearchParamsSetter>;
|
|
7
|
+
mockLocation: {
|
|
8
|
+
pathname: string;
|
|
9
|
+
search: string;
|
|
10
|
+
};
|
|
11
|
+
mockParams: {
|
|
12
|
+
id: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
1
15
|
/**
|
|
2
16
|
* Sets up a mock for use-context-selector that uses React's native context
|
|
3
17
|
* This allows tests to use context providers without the full use-context-selector implementation
|
|
@@ -7,17 +21,7 @@ export declare const setupContextSelectorMock: () => void;
|
|
|
7
21
|
* Sets up a mock for react-router with common defaults
|
|
8
22
|
* @param options - Override specific router behavior
|
|
9
23
|
*/
|
|
10
|
-
export declare const setupReactRouterMock: () =>
|
|
11
|
-
mockSearchParams: URLSearchParams;
|
|
12
|
-
mockSetParams: import("vitest").Mock<(...args: any[]) => any>;
|
|
13
|
-
mockLocation: {
|
|
14
|
-
pathname: string;
|
|
15
|
-
search: string;
|
|
16
|
-
};
|
|
17
|
-
mockParams: {
|
|
18
|
-
id: undefined;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
24
|
+
export declare const setupReactRouterMock: () => ReactRouterMock;
|
|
21
25
|
/**
|
|
22
26
|
* Sets up a mock localStorage instance
|
|
23
27
|
*/
|
|
@@ -26,3 +30,4 @@ export declare const setupLocalStorageMock: () => Storage;
|
|
|
26
30
|
* Sets up a mock sessionStorage instance
|
|
27
31
|
*/
|
|
28
32
|
export declare const setupSessionStorageMock: () => Storage;
|
|
33
|
+
export {};
|