Skip to content

Commit 54bb4ea

Browse files
committed
deeper mock cleanup
1 parent 778089d commit 54bb4ea

7 files changed

Lines changed: 8 additions & 55 deletions

File tree

labkey-ui-ehr/src/ParticipantHistory/APIWrapper.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ const mockFilterCreate = jest.fn((field: string, value: boolean | string | strin
1111

1212
// Mock @labkey/api Query.selectRows
1313
jest.mock('@labkey/api', () => ({
14-
...jest.requireActual('@labkey/api'),
1514
Query: {
16-
...jest.requireActual('@labkey/api').Query,
1715
selectRows: jest.fn(),
1816
},
1917
Filter: {

labkey-ui-ehr/src/ParticipantHistory/ParticipantReports.test.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ const mockFetchReports = jest.fn<Promise<FetchReportsResult>, []>();
1111

1212
// Mock Ext4 global
1313
const mockExt4Container = {
14-
report: null as any,
1514
filters: null as any,
1615
isDestroyed: false,
1716
add: jest.fn(),
1817
removeAll: jest.fn(),
1918
destroy: jest.fn(),
20-
getFilterArray: jest.fn(() => ({ removable: [], nonRemovable: [] })),
21-
getQWPConfig: jest.fn(() => ({})),
2219
};
2320

2421
(globalThis as any).Ext4 = {
@@ -872,7 +869,6 @@ describe('ParticipantReports', () => {
872869
.spyOn(APIWrapperModule, 'getDefaultParticipantHistoryAPIWrapper')
873870
.mockReturnValue({
874871
fetchReports: defaultFetchReports,
875-
resolveAnimalIds: jest.fn(),
876872
} as any);
877873

878874
try {

labkey-ui-ehr/src/ParticipantHistory/TabbedReportPanel/JSReportWrapper.test.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { ExtReportTab, FILTER_TYPE_ID_SEARCH, JsReportConfig } from '../models';
1010
jest.mock('@labkey/api', () => ({
1111
...jest.requireActual('@labkey/api'),
1212
Query: {
13-
...jest.requireActual('@labkey/api').Query,
1413
selectRows: jest.fn(),
1514
},
1615
}));
@@ -19,14 +18,9 @@ jest.mock('@labkey/api', () => ({
1918
let mockExt4Container: ExtReportTab;
2019

2120
const createMockContainer = (): ExtReportTab => ({
22-
report: null as any,
23-
filters: null as any,
24-
isDestroyed: false,
2521
add: jest.fn(),
2622
removeAll: jest.fn(),
2723
destroy: jest.fn(),
28-
getFilterArray: jest.fn(() => ({ removable: [], nonRemovable: [] })),
29-
getQWPConfig: jest.fn(() => ({})),
3024
});
3125

3226
(globalThis as any).Ext4 = {

labkey-ui-ehr/src/ParticipantHistory/TabbedReportPanel/OtherReportWrapper.test.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import { render, waitFor } from '@testing-library/react';
44
import { OtherReportWrapper } from './OtherReportWrapper';
55
import { ExtReportTab, FILTER_TYPE_ID_SEARCH, OtherReportConfig } from '../models';
66

7-
const createMockContainer = (): ExtReportTab => ({
8-
report: null as any,
9-
filters: null as any,
10-
isDestroyed: false,
11-
add: jest.fn(),
12-
removeAll: jest.fn(),
13-
destroy: jest.fn(),
14-
getFilterArray: jest.fn(() => ({ removable: [], nonRemovable: [] })),
15-
getQWPConfig: jest.fn(() => ({})),
16-
});
7+
const createMockContainer = (): ExtReportTab =>
8+
({
9+
add: jest.fn(),
10+
removeAll: jest.fn(),
11+
destroy: jest.fn(),
12+
} as unknown as ExtReportTab);
1713

1814
(globalThis as any).Ext4 = {
1915
create: jest.fn(() => createMockContainer()),

labkey-ui-ehr/src/ParticipantHistory/TabbedReportPanel/QueryReportWrapper.test.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,9 @@ import { defaultServerContext, renderWithServerContext } from '../../test/utils'
99
let mockExt4Container: ExtReportTab;
1010

1111
const createMockContainer = (): ExtReportTab => ({
12-
report: null as any,
13-
filters: null as any,
14-
isDestroyed: false,
1512
add: jest.fn(),
1613
removeAll: jest.fn(),
1714
destroy: jest.fn(),
18-
getFilterArray: jest.fn(() => ({ removable: [], nonRemovable: [] })),
19-
getQWPConfig: jest.fn(() => ({})),
2015
});
2116

2217
(globalThis as any).Ext4 = {

labkey-ui-ehr/src/ParticipantHistory/TabbedReportPanel/TabbedReportPanel.test.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@ import {
1515
} from '../models';
1616
import { defaultServerContext, renderWithServerContext } from '../../test/utils';
1717

18-
// Mock @labkey/api Query.selectRows and Filter.create
18+
// Mock @labkey/api Filter.create
1919
jest.mock('@labkey/api', () => {
2020
const actual = jest.requireActual('@labkey/api');
2121
return {
2222
...actual,
23-
Query: {
24-
...actual.Query,
25-
selectRows: jest.fn(),
26-
},
2723
Filter: {
2824
...actual.Filter,
2925
create: (field: string, value: string, type: any) => {
@@ -57,14 +53,9 @@ let capturedGetFilterArray: (() => FilterArray) | null = null;
5753
// Mock Ext4 global with Proxy to capture assigned methods
5854
const createMockExt4Container = () => {
5955
const container = {
60-
report: null as any,
61-
filters: null as any,
62-
isDestroyed: false,
6356
add: jest.fn(),
6457
removeAll: jest.fn(),
6558
destroy: jest.fn(),
66-
getFilterArray: jest.fn(() => ({ removable: [], nonRemovable: [] })),
67-
getQWPConfig: jest.fn(() => ({})),
6859
};
6960

7061
// Use Proxy to capture when getFilterArray is assigned
@@ -83,13 +74,6 @@ const createMockExt4Container = () => {
8374
create: jest.fn(() => createMockExt4Container()),
8475
};
8576

86-
// Mock LDK global for QueryReportWrapper
87-
(globalThis as any).LDK = {
88-
Utils: {
89-
getErrorCallback: jest.fn(() => jest.fn()),
90-
},
91-
};
92-
9377
// Mock LABKEY.WebPart for OtherReportWrapper
9478
(globalThis as any).LABKEY = {
9579
...(globalThis as any).LABKEY,

labkey-ui-ehr/src/ParticipantHistory/TabbedReportPanel/useReportTab.test.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,7 @@ let mockContainerInstances: any[] = [];
5151
// Factory to create mock containers that track method calls
5252
const createMockContainer = (): any => {
5353
const container = {
54-
report: null as any,
55-
filters: null as any,
56-
isDestroyed: false,
57-
add: jest.fn(),
58-
removeAll: jest.fn(),
59-
destroy: jest.fn(() => {
60-
container.isDestroyed = true;
61-
}),
62-
getFilterArray: jest.fn(() => ({ removable: [], nonRemovable: [] })),
63-
getQWPConfig: jest.fn(() => ({})),
54+
destroy: jest.fn(),
6455
};
6556
mockContainerInstances.push(container);
6657
return container;
@@ -104,7 +95,6 @@ describe('useReportTab', () => {
10495

10596
beforeEach(() => {
10697
jest.clearAllMocks();
107-
mockFilterCreate.mockClear();
10898
mockContainerInstances = [];
10999
});
110100

0 commit comments

Comments
 (0)