diff --git a/packages/pluggableWidgets/intro-screen-native/src/__tests__/IntroScreen.notch.spec.tsx b/packages/pluggableWidgets/intro-screen-native/src/__tests__/IntroScreen.notch.spec.tsx index aa448378f..487aa4cfc 100644 --- a/packages/pluggableWidgets/intro-screen-native/src/__tests__/IntroScreen.notch.spec.tsx +++ b/packages/pluggableWidgets/intro-screen-native/src/__tests__/IntroScreen.notch.spec.tsx @@ -1,9 +1,9 @@ import { createElement } from "react"; -import { render } from "@testing-library/react-native"; +import { render, act } from "@testing-library/react-native"; import { IntroScreen } from "../IntroScreen"; import { IntroScreenProps } from "../../typings/IntroScreenProps"; import { IntroScreenStyle } from "../ui/Styles"; -import { View } from "react-native"; +import { InteractionManager, View } from "react-native"; import { EditableValueBuilder } from "@mendix/piw-utils-internal"; import { Big } from "big.js"; @@ -13,10 +13,13 @@ jest.mock("react-native-device-info", () => ({ })); jest.mock("@react-native-async-storage/async-storage", () => ({ - getItem: jest.fn().mockResolvedValue("gone"), - setValue: jest.fn().mockResolvedValue(null) + getItem: jest.fn().mockResolvedValue(null), + setItem: jest.fn().mockResolvedValue(null) })); +const flushInteractions = (): Promise => + act(() => new Promise(resolve => InteractionManager.runAfterInteractions(resolve))); + describe("Intro Screen", () => { let defaultProps: IntroScreenProps; @@ -36,39 +39,42 @@ describe("Intro Screen", () => { hideIndicatorLastSlide: false, identifier: "" }; - - jest.useFakeTimers(); }); - it("renders", () => { + it("renders", async () => { const component = render(); + await flushInteractions(); expect(component.toJSON()).toMatchSnapshot(); }); - it("renders with 1 bottom button", () => { + it("renders with 1 bottom button", async () => { const component = render( ); + await flushInteractions(); expect(component.toJSON()).toMatchSnapshot(); }); - it("renders with 2 bottom button", () => { + it("renders with 2 bottom button", async () => { const component = render(); + await flushInteractions(); expect(component.toJSON()).toMatchSnapshot(); }); - it("renders with active slide attribute", () => { + it("renders with active slide attribute", async () => { const component = render( ().withValue(new Big(1)).build()} /> ); + await flushInteractions(); expect(component.toJSON()).toMatchSnapshot(); }); - it("renders with async storage identifier", () => { + it("renders with async storage identifier", async () => { const component = render(); + await flushInteractions(); expect(component.toJSON()).toMatchSnapshot(); }); }); diff --git a/packages/pluggableWidgets/intro-screen-native/src/__tests__/IntroScreen.spec.tsx b/packages/pluggableWidgets/intro-screen-native/src/__tests__/IntroScreen.spec.tsx index ada286a09..8441c8817 100644 --- a/packages/pluggableWidgets/intro-screen-native/src/__tests__/IntroScreen.spec.tsx +++ b/packages/pluggableWidgets/intro-screen-native/src/__tests__/IntroScreen.spec.tsx @@ -1,9 +1,9 @@ import { createElement } from "react"; -import { render } from "@testing-library/react-native"; +import { render, act } from "@testing-library/react-native"; +import { InteractionManager, View } from "react-native"; import { IntroScreen } from "../IntroScreen"; import { IntroScreenProps } from "../../typings/IntroScreenProps"; import { IntroScreenStyle } from "../ui/Styles"; -import { View } from "react-native"; import { EditableValueBuilder } from "@mendix/piw-utils-internal"; import { Big } from "big.js"; @@ -13,10 +13,13 @@ jest.mock("react-native-device-info", () => ({ })); jest.mock("@react-native-async-storage/async-storage", () => ({ - getItem: jest.fn().mockResolvedValue("gone"), - setValue: jest.fn().mockResolvedValue(null) + getItem: jest.fn().mockResolvedValue(null), + setItem: jest.fn().mockResolvedValue(null) })); +const flushInteractions = (): Promise => + act(() => new Promise(resolve => InteractionManager.runAfterInteractions(resolve))); + describe("Intro Screen", () => { let defaultProps: IntroScreenProps; @@ -41,39 +44,42 @@ describe("Intro Screen", () => { hasNotch: jest.fn(), getDeviceId: jest.fn().mockReturnValue("iPhone") })); - - jest.useFakeTimers(); }); - it("renders", () => { + it("renders", async () => { const component = render(); + await flushInteractions(); expect(component.toJSON()).toMatchSnapshot(); }); - it("renders with 1 bottom button", () => { + it("renders with 1 bottom button", async () => { const component = render( ); + await flushInteractions(); expect(component.toJSON()).toMatchSnapshot(); }); - it("renders with 2 bottom button", () => { + it("renders with 2 bottom button", async () => { const component = render(); + await flushInteractions(); expect(component.toJSON()).toMatchSnapshot(); }); - it("renders with active slide attribute", () => { + it("renders with active slide attribute", async () => { const component = render( ().withValue(new Big(1)).build()} /> ); + await flushInteractions(); expect(component.toJSON()).toMatchSnapshot(); }); - it("renders with async storage identifier", () => { + it("renders with async storage identifier", async () => { const component = render(); + await flushInteractions(); expect(component.toJSON()).toMatchSnapshot(); }); }); diff --git a/packages/pluggableWidgets/intro-screen-native/src/__tests__/__snapshots__/IntroScreen.notch.spec.tsx.snap b/packages/pluggableWidgets/intro-screen-native/src/__tests__/__snapshots__/IntroScreen.notch.spec.tsx.snap index 4c7d1018a..84d21083a 100644 --- a/packages/pluggableWidgets/intro-screen-native/src/__tests__/__snapshots__/IntroScreen.notch.spec.tsx.snap +++ b/packages/pluggableWidgets/intro-screen-native/src/__tests__/__snapshots__/IntroScreen.notch.spec.tsx.snap @@ -1,11 +1,1014 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Intro Screen renders 1`] = `null`; +exports[`Intro Screen renders 1`] = ` + + + + , + "name": "Page 1", + }, + ] + } + extraData={ + [ + 0, + 0, + ] + } + getItem={[Function]} + getItemCount={[Function]} + getItemLayout={[Function]} + horizontal={true} + importantForAccessibility="no" + initialScrollIndex={0} + keyExtractor={[Function]} + onContentSizeChange={[Function]} + onLayout={[Function]} + onMomentumScrollBegin={[Function]} + onMomentumScrollEnd={[Function]} + onScroll={[Function]} + onScrollBeginDrag={[Function]} + onScrollEndDrag={[Function]} + pagingEnabled={true} + removeClippedSubviews={true} + renderItem={[Function]} + scrollEventThrottle={50} + showsHorizontalScrollIndicator={false} + stickyHeaderIndices={[]} + style={ + { + "flex": 1, + "flexDirection": "row", + } + } + testID="intro-screen-notch-test" + viewabilityConfigCallbackPairs={[]} + > + + + + + + + + + + + + + + + + + + + +`; -exports[`Intro Screen renders with 1 bottom button 1`] = `null`; +exports[`Intro Screen renders with 1 bottom button 1`] = ` + + + + , + "name": "Page 1", + }, + ] + } + extraData={ + [ + 0, + 0, + ] + } + getItem={[Function]} + getItemCount={[Function]} + getItemLayout={[Function]} + horizontal={true} + importantForAccessibility="no" + initialScrollIndex={0} + keyExtractor={[Function]} + onContentSizeChange={[Function]} + onLayout={[Function]} + onMomentumScrollBegin={[Function]} + onMomentumScrollEnd={[Function]} + onScroll={[Function]} + onScrollBeginDrag={[Function]} + onScrollEndDrag={[Function]} + pagingEnabled={true} + removeClippedSubviews={true} + renderItem={[Function]} + scrollEventThrottle={50} + showsHorizontalScrollIndicator={false} + stickyHeaderIndices={[]} + style={ + { + "flex": 1, + "flexDirection": "row", + } + } + testID="intro-screen-notch-test" + viewabilityConfigCallbackPairs={[]} + > + + + + + + + + + + + + + + + + + + + + + + + +`; -exports[`Intro Screen renders with 2 bottom button 1`] = `null`; +exports[`Intro Screen renders with 2 bottom button 1`] = ` + + + + , + "name": "Page 1", + }, + ] + } + extraData={ + [ + 0, + 0, + ] + } + getItem={[Function]} + getItemCount={[Function]} + getItemLayout={[Function]} + horizontal={true} + importantForAccessibility="no" + initialScrollIndex={0} + keyExtractor={[Function]} + onContentSizeChange={[Function]} + onLayout={[Function]} + onMomentumScrollBegin={[Function]} + onMomentumScrollEnd={[Function]} + onScroll={[Function]} + onScrollBeginDrag={[Function]} + onScrollEndDrag={[Function]} + pagingEnabled={true} + removeClippedSubviews={true} + renderItem={[Function]} + scrollEventThrottle={50} + showsHorizontalScrollIndicator={false} + stickyHeaderIndices={[]} + style={ + { + "flex": 1, + "flexDirection": "row", + } + } + testID="intro-screen-notch-test" + viewabilityConfigCallbackPairs={[]} + > + + + + + + + + + + + + + + + + + + + + + + + +`; -exports[`Intro Screen renders with active slide attribute 1`] = `null`; +exports[`Intro Screen renders with active slide attribute 1`] = ` + + + + , + "name": "Page 1", + }, + ] + } + extraData={ + [ + 0, + 0, + ] + } + getItem={[Function]} + getItemCount={[Function]} + getItemLayout={[Function]} + horizontal={true} + importantForAccessibility="no" + initialScrollIndex={0} + keyExtractor={[Function]} + onContentSizeChange={[Function]} + onLayout={[Function]} + onMomentumScrollBegin={[Function]} + onMomentumScrollEnd={[Function]} + onScroll={[Function]} + onScrollBeginDrag={[Function]} + onScrollEndDrag={[Function]} + pagingEnabled={true} + removeClippedSubviews={true} + renderItem={[Function]} + scrollEventThrottle={50} + showsHorizontalScrollIndicator={false} + stickyHeaderIndices={[]} + style={ + { + "flex": 1, + "flexDirection": "row", + } + } + testID="intro-screen-notch-test" + viewabilityConfigCallbackPairs={[]} + > + + + + + + + + + + + + + + + + + + + +`; -exports[`Intro Screen renders with async storage identifier 1`] = `null`; +exports[`Intro Screen renders with async storage identifier 1`] = ` + + + + , + "name": "Page 1", + }, + ] + } + extraData={ + [ + 0, + 0, + ] + } + getItem={[Function]} + getItemCount={[Function]} + getItemLayout={[Function]} + horizontal={true} + importantForAccessibility="no" + initialScrollIndex={0} + keyExtractor={[Function]} + onContentSizeChange={[Function]} + onLayout={[Function]} + onMomentumScrollBegin={[Function]} + onMomentumScrollEnd={[Function]} + onScroll={[Function]} + onScrollBeginDrag={[Function]} + onScrollEndDrag={[Function]} + pagingEnabled={true} + removeClippedSubviews={true} + renderItem={[Function]} + scrollEventThrottle={50} + showsHorizontalScrollIndicator={false} + stickyHeaderIndices={[]} + style={ + { + "flex": 1, + "flexDirection": "row", + } + } + testID="intro-screen-notch-test" + viewabilityConfigCallbackPairs={[]} + > + + + + + + + + + + + + + + + + + + + +`; diff --git a/packages/pluggableWidgets/intro-screen-native/src/__tests__/__snapshots__/IntroScreen.spec.tsx.snap b/packages/pluggableWidgets/intro-screen-native/src/__tests__/__snapshots__/IntroScreen.spec.tsx.snap index 4c7d1018a..af56b5303 100644 --- a/packages/pluggableWidgets/intro-screen-native/src/__tests__/__snapshots__/IntroScreen.spec.tsx.snap +++ b/packages/pluggableWidgets/intro-screen-native/src/__tests__/__snapshots__/IntroScreen.spec.tsx.snap @@ -1,11 +1,1014 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Intro Screen renders 1`] = `null`; +exports[`Intro Screen renders 1`] = ` + + + + , + "name": "Page 1", + }, + ] + } + extraData={ + [ + 0, + 0, + ] + } + getItem={[Function]} + getItemCount={[Function]} + getItemLayout={[Function]} + horizontal={true} + importantForAccessibility="no" + initialScrollIndex={0} + keyExtractor={[Function]} + onContentSizeChange={[Function]} + onLayout={[Function]} + onMomentumScrollBegin={[Function]} + onMomentumScrollEnd={[Function]} + onScroll={[Function]} + onScrollBeginDrag={[Function]} + onScrollEndDrag={[Function]} + pagingEnabled={true} + removeClippedSubviews={true} + renderItem={[Function]} + scrollEventThrottle={50} + showsHorizontalScrollIndicator={false} + stickyHeaderIndices={[]} + style={ + { + "flex": 1, + "flexDirection": "row", + } + } + testID="intro-screen-test" + viewabilityConfigCallbackPairs={[]} + > + + + + + + + + + + + + + + + + + + + +`; -exports[`Intro Screen renders with 1 bottom button 1`] = `null`; +exports[`Intro Screen renders with 1 bottom button 1`] = ` + + + + , + "name": "Page 1", + }, + ] + } + extraData={ + [ + 0, + 0, + ] + } + getItem={[Function]} + getItemCount={[Function]} + getItemLayout={[Function]} + horizontal={true} + importantForAccessibility="no" + initialScrollIndex={0} + keyExtractor={[Function]} + onContentSizeChange={[Function]} + onLayout={[Function]} + onMomentumScrollBegin={[Function]} + onMomentumScrollEnd={[Function]} + onScroll={[Function]} + onScrollBeginDrag={[Function]} + onScrollEndDrag={[Function]} + pagingEnabled={true} + removeClippedSubviews={true} + renderItem={[Function]} + scrollEventThrottle={50} + showsHorizontalScrollIndicator={false} + stickyHeaderIndices={[]} + style={ + { + "flex": 1, + "flexDirection": "row", + } + } + testID="intro-screen-test" + viewabilityConfigCallbackPairs={[]} + > + + + + + + + + + + + + + + + + + + + + + + + +`; -exports[`Intro Screen renders with 2 bottom button 1`] = `null`; +exports[`Intro Screen renders with 2 bottom button 1`] = ` + + + + , + "name": "Page 1", + }, + ] + } + extraData={ + [ + 0, + 0, + ] + } + getItem={[Function]} + getItemCount={[Function]} + getItemLayout={[Function]} + horizontal={true} + importantForAccessibility="no" + initialScrollIndex={0} + keyExtractor={[Function]} + onContentSizeChange={[Function]} + onLayout={[Function]} + onMomentumScrollBegin={[Function]} + onMomentumScrollEnd={[Function]} + onScroll={[Function]} + onScrollBeginDrag={[Function]} + onScrollEndDrag={[Function]} + pagingEnabled={true} + removeClippedSubviews={true} + renderItem={[Function]} + scrollEventThrottle={50} + showsHorizontalScrollIndicator={false} + stickyHeaderIndices={[]} + style={ + { + "flex": 1, + "flexDirection": "row", + } + } + testID="intro-screen-test" + viewabilityConfigCallbackPairs={[]} + > + + + + + + + + + + + + + + + + + + + + + + + +`; -exports[`Intro Screen renders with active slide attribute 1`] = `null`; +exports[`Intro Screen renders with active slide attribute 1`] = ` + + + + , + "name": "Page 1", + }, + ] + } + extraData={ + [ + 0, + 0, + ] + } + getItem={[Function]} + getItemCount={[Function]} + getItemLayout={[Function]} + horizontal={true} + importantForAccessibility="no" + initialScrollIndex={0} + keyExtractor={[Function]} + onContentSizeChange={[Function]} + onLayout={[Function]} + onMomentumScrollBegin={[Function]} + onMomentumScrollEnd={[Function]} + onScroll={[Function]} + onScrollBeginDrag={[Function]} + onScrollEndDrag={[Function]} + pagingEnabled={true} + removeClippedSubviews={true} + renderItem={[Function]} + scrollEventThrottle={50} + showsHorizontalScrollIndicator={false} + stickyHeaderIndices={[]} + style={ + { + "flex": 1, + "flexDirection": "row", + } + } + testID="intro-screen-test" + viewabilityConfigCallbackPairs={[]} + > + + + + + + + + + + + + + + + + + + + +`; -exports[`Intro Screen renders with async storage identifier 1`] = `null`; +exports[`Intro Screen renders with async storage identifier 1`] = ` + + + + , + "name": "Page 1", + }, + ] + } + extraData={ + [ + 0, + 0, + ] + } + getItem={[Function]} + getItemCount={[Function]} + getItemLayout={[Function]} + horizontal={true} + importantForAccessibility="no" + initialScrollIndex={0} + keyExtractor={[Function]} + onContentSizeChange={[Function]} + onLayout={[Function]} + onMomentumScrollBegin={[Function]} + onMomentumScrollEnd={[Function]} + onScroll={[Function]} + onScrollBeginDrag={[Function]} + onScrollEndDrag={[Function]} + pagingEnabled={true} + removeClippedSubviews={true} + renderItem={[Function]} + scrollEventThrottle={50} + showsHorizontalScrollIndicator={false} + stickyHeaderIndices={[]} + style={ + { + "flex": 1, + "flexDirection": "row", + } + } + testID="intro-screen-test" + viewabilityConfigCallbackPairs={[]} + > + + + + + + + + + + + + + + + + + + + +`;