Skip to content

Commit 3c4be7e

Browse files
committed
Improve Fullstory mocks
1 parent a9b3913 commit 3c4be7e

10 files changed

Lines changed: 17 additions & 62 deletions

jest/setupMockFullstoryLib.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
type FSPageInterface = {
2-
start: jest.Mock<void, []>;
3-
};
1+
import type {Fullstory, FSPageLike as mockFSPageLike} from '@libs/Fullstory/types';
42

53
export default function mockFSLibrary() {
64
jest.mock('@fullstory/react-native', () => {
7-
class Fullstory {
8-
consent = jest.fn();
9-
10-
anonymize = jest.fn();
5+
return {
6+
FSPage: jest.fn(),
7+
default: jest.fn(),
8+
};
9+
});
1110

12-
identify = jest.fn();
11+
jest.mock<Fullstory>('@libs/Fullstory', () => {
12+
class FSPage implements mockFSPageLike {
13+
start() {}
1314
}
1415

1516
return {
16-
FSPage(): FSPageInterface {
17-
return {
18-
start: jest.fn(() => {}),
19-
};
20-
},
21-
default: Fullstory,
17+
Page: FSPage,
18+
getChatFSClass: jest.fn(),
19+
init: jest.fn(),
20+
onReady: jest.fn(),
21+
consent: jest.fn(),
22+
identify: jest.fn(),
23+
consentAndIdentify: jest.fn(),
24+
anonymize: jest.fn(),
2225
};
2326
});
2427
}

tests/navigation/GoBackTests.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ import TestNavigationContainer from '../utils/TestNavigationContainer';
1313
jest.mock('@hooks/useResponsiveLayout', () => jest.fn());
1414
jest.mock('@libs/getIsNarrowLayout', () => jest.fn());
1515

16-
// Mock Fullstory library dependency
17-
jest.mock('@libs/Fullstory', () => ({
18-
default: {
19-
consentAndIdentify: jest.fn(),
20-
},
21-
}));
22-
2316
jest.mock('@pages/home/sidebar/NavigationTabBarAvatar');
2417
jest.mock('@src/components/Navigation/TopLevelNavigationTabBar');
2518

tests/navigation/NavigateTests.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ import TestNavigationContainer from '../utils/TestNavigationContainer';
1313
jest.mock('@hooks/useResponsiveLayout', () => jest.fn());
1414
jest.mock('@libs/getIsNarrowLayout', () => jest.fn());
1515

16-
// Mock Fullstory library dependency
17-
jest.mock('@libs/Fullstory', () => ({
18-
default: {
19-
consentAndIdentify: jest.fn(),
20-
},
21-
}));
22-
2316
jest.mock('@pages/home/sidebar/NavigationTabBarAvatar');
2417
jest.mock('@src/components/Navigation/TopLevelNavigationTabBar');
2518

tests/navigation/ResizeScreenTests.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ jest.mock('@libs/getIsNarrowLayout', () => jest.fn());
2121

2222
jest.mock('@pages/settings/InitialSettingsPage');
2323
jest.mock('@pages/settings/Profile/ProfilePage');
24-
// Mock Fullstory library dependency
25-
jest.mock('@libs/Fullstory', () => ({
26-
default: {
27-
consentAndIdentify: jest.fn(),
28-
},
29-
}));
3024

3125
const INITIAL_STATE = {
3226
index: 0,

tests/navigation/isActiveRouteTests.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ import TestNavigationContainer from '../utils/TestNavigationContainer';
1212
jest.mock('@hooks/useResponsiveLayout', () => jest.fn());
1313
jest.mock('@libs/getIsNarrowLayout', () => jest.fn());
1414

15-
// Mock Fullstory library dependency
16-
jest.mock('@libs/Fullstory', () => ({
17-
default: {
18-
consentAndIdentify: jest.fn(),
19-
},
20-
}));
21-
2215
jest.mock('@pages/home/sidebar/NavigationTabBarAvatar');
2316
jest.mock('@src/components/Navigation/TopLevelNavigationTabBar');
2417

tests/perf-test/ReportActionsList.perf-test.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ type LazyLoadLHNTestUtils = {
2525

2626
const mockedNavigate = jest.fn();
2727

28-
// Mock Fullstory library dependency
29-
jest.mock('@libs/Fullstory', () => ({
30-
default: {
31-
consentAndIdentify: jest.fn(),
32-
},
33-
}));
34-
3528
jest.mock('@components/withCurrentUserPersonalDetails', () => {
3629
// Lazy loading of LHNTestUtils
3730
const lazyLoadLHNTestUtils = () => require<LazyLoadLHNTestUtils>('../utils/LHNTestUtils');

tests/ui/components/FeatureTrainingModalTest.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jest.mock('@libs/Navigation/Navigation', () => ({
2222
getActiveRoute: jest.fn(() => '/'),
2323
}));
2424

25-
jest.mock('@libs/Fullstory');
2625
jest.mock('expo-av', () => {
2726
const {View} = require<typeof ReactNative>('react-native');
2827
// eslint-disable-next-line @typescript-eslint/no-unsafe-return

tests/ui/components/IOURequestStepConfirmationPageTest.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jest.mock('@libs/actions/IOU', () => {
2525
startMoneyRequest: jest.fn(),
2626
};
2727
});
28-
jest.mock('@libs/Fullstory');
2928
jest.mock('@components/ProductTrainingContext', () => ({
3029
useProductTrainingContext: () => [false],
3130
}));

tests/ui/components/ProductTrainingContextProvider.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ jest.mock('@hooks/useResponsiveLayout', () => ({
1818
default: jest.fn(),
1919
}));
2020

21-
// Mock Fullstory library dependency
22-
jest.mock('@libs/Fullstory', () => ({
23-
default: {
24-
consentAndIdentify: jest.fn(),
25-
},
26-
}));
27-
2821
const DEFAULT_USE_RESPONSIVE_LAYOUT_VALUE = {
2922
shouldUseNarrowLayout: true,
3023
isSmallScreenWidth: true,

tests/ui/components/TabSelectorItem.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ import Tooltip from '@components/Tooltip';
55

66
// Mock the Tooltip component since it uses portals which aren't supported in RNTL
77
jest.mock('@components/Tooltip');
8-
jest.mock('@libs/Fullstory', () => ({
9-
default: {
10-
consentAndIdentify: jest.fn(),
11-
},
12-
}));
138

149
describe('TabSelectorItem Component', () => {
1510
const title = 'Test Tab';

0 commit comments

Comments
 (0)