@applicaster/zapp-react-native-utils
Version:
Applicaster Zapp React Native utilities package
42 lines (35 loc) • 1.05 kB
JavaScript
describe("sendLaunchEvent", () => {
beforeEach(() => {
jest.resetModules();
});
it("skips the event when bridge does not exist", () => {
jest.doMock("react-native", () => ({
NativeModules: {},
Platform: {
OS: "web",
},
}));
const analyticsUtils = require("../index");
const { NativeModules } = require("react-native");
const { AnalyticsBridge } = NativeModules;
analyticsUtils.sendLaunchEvent();
expect(AnalyticsBridge?.postEvent).not.toBeDefined();
});
it("posts the event when bridge exist and is web based device", () => {
jest.doMock("react-native", () => ({
NativeModules: {
AnalyticsBridge: {
postEvent: jest.fn(),
},
},
Platform: {
OS: "web",
},
}));
const analyticsUtils = require("../index");
const { NativeModules } = require("react-native");
const { AnalyticsBridge } = NativeModules;
analyticsUtils.sendLaunchEvent();
expect(AnalyticsBridge.postEvent).toHaveBeenCalled();
});
});