UNPKG

@applicaster/zapp-react-native-bridge

Version:

Applicaster Zapp React Native modules

58 lines (45 loc) 1.27 kB
const { NativeModules } = require("react-native"); NativeModules.Foo = jest.fn(); jest.mock("../../logger", () => ({ bridgeLogger: { warning: jest.fn(), }, })); const { sendQuickBrickEvent, getAppData, getLegacyInitialProps, } = require("../"); const eventName = "event"; const payload = {}; const { bridgeLogger } = require("../../logger"); describe("when QuickBrickCommunication Module is undefined", () => { beforeEach(() => { jest.unmock("react-native"); jest.resetModules(); }); describe("sendQuickBrickEvent", () => { it("throws an error", () => { expect(() => sendQuickBrickEvent(eventName, payload)).toThrow(); }); }); describe("getAppData", () => { it("returns the default values", () => { expect(getAppData()).toMatchSnapshot(); }); }); describe("getLegacyInitialProps", () => { beforeEach(() => { bridgeLogger.warning.mockClear(); }); it("returns an empty object", () => { expect(getLegacyInitialProps()).toEqual({}); }); it("warns in the console that the module is missing", () => { getLegacyInitialProps(); expect(bridgeLogger.warning).toHaveBeenCalledWith( "QuickBrickCommunicationModule not found" ); }); }); });