Skip to content

Commit

Permalink
fix mock
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasMassart committed Sep 23, 2024
1 parent a42b3ad commit 07b9037
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
18 changes: 0 additions & 18 deletions app/core/Analytics/MetaMetricsPrivacySegmentPlugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
jest.mock('@segment/analytics-react-native', () => ({
PluginType: {
enrichment: 'enrichment',
utility: 'utility',
},
EventType: {
TrackEvent: 'track',
IdentifyEvent: 'identify',
},
Plugin: class Plugin {
type = 'utility';
analytics: SegmentClient | undefined;
configure(analytics: SegmentClient) {
this.analytics = analytics;
}
},
}));

import MetaMetricsPrivacySegmentPlugin from './MetaMetricsPrivacySegmentPlugin';
import METAMETRICS_ANONYMOUS_ID from './MetaMetrics.constants';

Expand Down
28 changes: 25 additions & 3 deletions app/util/test/testSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import mockClipboard from '@react-native-clipboard/clipboard/jest/clipboard-mock
import { mockTheme } from '../theme';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme from 'enzyme';
import { SegmentClient } from '@segment/analytics-react-native';

Enzyme.configure({ adapter: new Adapter() });

Expand Down Expand Up @@ -283,13 +284,34 @@ const initializeMockClient = () => {
group: jest.fn(),
alias: jest.fn(),
reset: jest.fn(),
add: jest.fn(),
};
return global.segmentMockClient;
};

jest.mock('@segment/analytics-react-native', () => ({
createClient: jest.fn(() => initializeMockClient()),
}));
jest.mock('@segment/analytics-react-native', () => {
class Plugin {
type = 'utility';
analytics = undefined;

configure(analytics) {
this.analytics = analytics;
}
}

return {
createClient: jest.fn(() => initializeMockClient()),
PluginType: {
enrichment: 'enrichment',
utility: 'utility',
},
EventType: {
TrackEvent: 'track',
IdentifyEvent: 'identify',
},
Plugin,
};
});

jest.mock('@notifee/react-native', () =>
require('@notifee/react-native/jest-mock'),
Expand Down

0 comments on commit 07b9037

Please sign in to comment.