Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IOCOM-1848] Analytics for Push Notifications Engagement #6598

Merged
merged 19 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tests for SettingsDiscoveryBanner
Vangaorth committed Jan 10, 2025
commit 8583e593e653ab38585a618d58171374420846e0
Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@ export const SettingsDiscoveryBanner = ({
onClose={closeHandler}
labelClose={I18n.t("global.buttons.close")}
onPress={handleOnPress}
testID="settingsDiscoveryBannerCTA"
/>
</View>
);
Original file line number Diff line number Diff line change
@@ -1,19 +1,61 @@
import * as React from "react";
import { createStore } from "redux";
import { constUndefined } from "fp-ts/lib/function";
import ROUTES from "../../../../navigation/routes";
import { applicationChangeState } from "../../../../store/actions/application";
import { appReducer } from "../../../../store/reducers";
import { GlobalState } from "../../../../store/reducers/types";
import { renderScreenWithNavigationStoreContext } from "../../../../utils/testWrapper";
import { SettingsDiscoveryBanner } from "../SettingsDiscoveryBanner";
import * as analytics from "../../analytics";
import { fireEvent } from "@testing-library/react-native";
import I18n from "../../../../i18n";

describe("settingsDiscoveryBanner", () => {
afterEach(() => {
jest.restoreAllMocks();
});
it("should match snapshot", () => {
const component = renderComponent(
<SettingsDiscoveryBanner handleOnClose={() => null} />
);
expect(component.toJSON()).toMatchSnapshot();
});
it("should have called 'trackSettingsDiscoverBannerVisualized' on first rendering", () => {
const spyOnMockedTrackSettingsDiscoverBannerVisualized = jest
.spyOn(analytics, "trackSettingsDiscoverBannerVisualized")
.mockImplementation(constUndefined);
renderComponent(<SettingsDiscoveryBanner handleOnClose={() => null} />);
expect(
spyOnMockedTrackSettingsDiscoverBannerVisualized
).toHaveBeenCalledTimes(1);
});
it("should have called 'trackSettingsDiscoverBannerTap' on first rendering", () => {
const spyOnMockedTrackSettingsDiscoverBannerTap = jest
.spyOn(analytics, "trackSettingsDiscoverBannerTap")
.mockImplementation(constUndefined);
const component = renderComponent(
<SettingsDiscoveryBanner handleOnClose={() => null} />
);
const cta = component.getByTestId("settingsDiscoveryBannerCTA");
fireEvent(cta, "press");
expect(spyOnMockedTrackSettingsDiscoverBannerTap).toHaveBeenCalledTimes(1);
});
it("should have called 'trackSettingsDiscoverBannerClosure' on first rendering", () => {
const spyOnMockedTrackSettingsDiscoverBannerClosure = jest
.spyOn(analytics, "trackSettingsDiscoverBannerClosure")
.mockImplementation(constUndefined);
const component = renderComponent(
<SettingsDiscoveryBanner handleOnClose={() => null} />
);
const closeButton = component.getByA11yLabel(
I18n.t("global.buttons.close")
);
fireEvent(closeButton, "press");
expect(spyOnMockedTrackSettingsDiscoverBannerClosure).toHaveBeenCalledTimes(
1
);
});
});

const renderComponent = (component: React.ReactElement) => {
Original file line number Diff line number Diff line change
@@ -372,6 +372,7 @@ exports[`settingsDiscoveryBanner should match snapshot 1`] = `
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
testID="settingsDiscoveryBannerCTA"
>
<View
style={