@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
31 lines • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @jest-environment jsdom
*/
const react_1 = require("@testing-library/react");
const featureFlags_1 = require("../../../../featureFlags");
const useSwapLiveConfig_1 = require("./useSwapLiveConfig");
// Explicitly mock the featureFlags module
jest.mock("../../../../featureFlags");
// Setup mock for useFeature to be recognized as a jest.Mock
const useMockFeature = featureFlags_1.useFeature;
describe("useSwapLiveConfig", () => {
// Setup the mock for useFeatureFlags to return an object with getFeature
const setupFeatureFlagsMock = (flags) => {
const flagsKeys = ["ptxSwapLiveApp"];
useMockFeature.mockImplementation(flagName => flags[flagsKeys.indexOf(flagName)] ?? null);
};
afterEach(() => {
jest.clearAllMocks();
});
it("should return demoThree config", () => {
setupFeatureFlagsMock([{ enabled: true, params: { manifest_id: "swap-live-app-demo-3" } }]);
const { result } = (0, react_1.renderHook)(() => (0, useSwapLiveConfig_1.useSwapLiveConfig)());
expect(result.current).toEqual({
enabled: true,
params: { manifest_id: "swap-live-app-demo-3" },
});
});
});
//# sourceMappingURL=useSwapLiveConfig.test.js.map