UNPKG

@applicaster/zapp-react-dom-app

Version:

Zapp App Component for Applicaster's Quick Brick React Native App

85 lines (69 loc) 2.4 kB
// TODO: finalize implementation of test import { appLoaderImpl as appLoader } from "../appLoader"; const dispatch = jest.fn(); const getState = jest.fn(() => ({ plugins: [{}, {}], pluginConfigurations: [{}], remoteConfigurations: { localizations: { en: "http://en.url", fr: "http://fr.url" }, }, })); const loadSessionStorageData = jest.fn(async () => {}); const loadAnalyticsPlugins = jest.fn(async () => {}); const loadDomPlugins = jest.fn(async () => {}); const loadLocale = jest.fn(async () => {}); const setUpRTL = jest.fn(async () => {}); describe("appLoaderImpl", () => { beforeEach(() => { jest.clearAllMocks(); }); it("calls appLoader", async () => { const appLoaderResult = appLoader( loadSessionStorageData, loadAnalyticsPlugins, loadDomPlugins, loadLocale, setUpRTL )(dispatch, getState); await expect(appLoaderResult).resolves.toBeUndefined(); }); // it("runs all loaders in sequence", async () => { // const appLoaderResult = appLoader( // loadSessionStorageData, // loadAnalyticsPlugins, // loadDomPlugins, // loadLocale, // setUpRTL // )(dispatch, getState); // await expect(appLoaderResult).resolves.toBeUndefined(); // // Verify the call order // await expect(loadLocale).toHaveBeenCalledBefore(loadSessionStorageData); // await expect(loadSessionStorageData).toHaveBeenCalledBefore( // loadAnalyticsPlugins // ); // const { // plugins, // pluginConfigurations, // remoteConfigurations: { localizations }, // } = getState(); // // Verify arguments // expect(loadAnalyticsPlugins).toHaveBeenCalledWith( // plugins, // pluginConfigurations // ); // expect(loadDomPlugins).toHaveBeenCalledWith(plugins); // expect(setUpRTL).toHaveBeenCalledWith(localizations); // }); // it("rejects the promise when an error is thrown", async () => { // // Let's assume loadAnalyticsPlugins fails // loadAnalyticsPlugins.mockRejectedValueOnce(new Error("An error occurred")); // const appLoaderResult = appLoader( // loadSessionStorageData, // loadAnalyticsPlugins, // loadDomPlugins, // loadLocale, // setUpRTL // )(dispatch, getState); // await expect(appLoaderResult).rejects.toThrow("An error occurred"); // }); });