Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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";
Expand All @@ -13,8 +13,8 @@ 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)
}));

describe("Intro Screen", () => {
Expand All @@ -36,39 +36,52 @@ describe("Intro Screen", () => {
hideIndicatorLastSlide: false,
identifier: ""
};

jest.useFakeTimers();
});

it("renders", () => {
it("renders", async () => {
const component = render(<IntroScreen {...defaultProps} />);
await act(async () => {
Comment thread
MxKevinBeqo marked this conversation as resolved.
Outdated
/* Wait for any async operations to complete */
});
expect(component.toJSON()).toMatchSnapshot();
});

it("renders with 1 bottom button", () => {
it("renders with 1 bottom button", async () => {
const component = render(
<IntroScreen {...defaultProps} slideIndicators={"above"} buttonPattern={"nextDone"} />
);
await act(async () => {
/* Wait for any async operations to complete */
});
expect(component.toJSON()).toMatchSnapshot();
});

it("renders with 2 bottom button", () => {
it("renders with 2 bottom button", async () => {
const component = render(<IntroScreen {...defaultProps} slideIndicators={"above"} buttonPattern={"all"} />);
await act(async () => {
/* Wait for any async operations to complete */
});
expect(component.toJSON()).toMatchSnapshot();
});

it("renders with active slide attribute", () => {
it("renders with active slide attribute", async () => {
const component = render(
<IntroScreen
{...defaultProps}
activeSlideAttribute={new EditableValueBuilder<Big>().withValue(new Big(1)).build()}
/>
);
await act(async () => {
/* Wait for any async operations to complete */
});
expect(component.toJSON()).toMatchSnapshot();
});

it("renders with async storage identifier", () => {
it("renders with async storage identifier", async () => {
const component = render(<IntroScreen {...defaultProps} identifier="test1" />);
await act(async () => {
/* Wait for any async operations to complete */
});
expect(component.toJSON()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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";
Expand All @@ -13,8 +13,8 @@ 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)
}));

describe("Intro Screen", () => {
Expand All @@ -41,39 +41,52 @@ describe("Intro Screen", () => {
hasNotch: jest.fn(),
getDeviceId: jest.fn().mockReturnValue("iPhone")
}));

jest.useFakeTimers();
});

it("renders", () => {
it("renders", async () => {
const component = render(<IntroScreen {...defaultProps} />);
await act(async () => {
/* Wait for any async operations to complete */
});
expect(component.toJSON()).toMatchSnapshot();
});

it("renders with 1 bottom button", () => {
it("renders with 1 bottom button", async () => {
const component = render(
<IntroScreen {...defaultProps} slideIndicators={"above"} buttonPattern={"nextDone"} />
);
await act(async () => {
/* Wait for any async operations to complete */
});
expect(component.toJSON()).toMatchSnapshot();
});

it("renders with 2 bottom button", () => {
it("renders with 2 bottom button", async () => {
const component = render(<IntroScreen {...defaultProps} slideIndicators={"above"} buttonPattern={"all"} />);
await act(async () => {
/* Wait for any async operations to complete */
});
expect(component.toJSON()).toMatchSnapshot();
});

it("renders with active slide attribute", () => {
it("renders with active slide attribute", async () => {
const component = render(
<IntroScreen
{...defaultProps}
activeSlideAttribute={new EditableValueBuilder<Big>().withValue(new Big(1)).build()}
/>
);
await act(async () => {
/* Wait for any async operations to complete */
});
expect(component.toJSON()).toMatchSnapshot();
});

it("renders with async storage identifier", () => {
it("renders with async storage identifier", async () => {
const component = render(<IntroScreen {...defaultProps} identifier="test1" />);
await act(async () => {
/* Wait for any async operations to complete */
});
expect(component.toJSON()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,199 @@ exports[`Intro Screen renders with 2 bottom button 1`] = `null`;

exports[`Intro Screen renders with active slide attribute 1`] = `null`;

exports[`Intro Screen renders with async storage identifier 1`] = `null`;
exports[`Intro Screen renders with async storage identifier 1`] = `
<Modal
hardwareAccelerated={false}
transparent={false}
visible={true}
>
<View
style={
{
"bottom": 0,
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
}
}
>
<View
style={
{
"flex": 1,
}
}
>
<RCTScrollView
bounces={false}
data={
[
{
"content": <View />,
"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={[]}
>
<View>
<View
onFocusCapture={[Function]}
style={
[
{
"flexDirection": "row",
},
null,
]
}
>
<View
accessibilityElementsHidden={false}
importantForAccessibility="auto"
style={
[
{
"flex": 1,
"width": 0,
},
]
}
>
<View />
</View>
</View>
</View>
</RCTScrollView>
<View
style={
[
{
"alignItems": "center",
"bottom": 22,
"justifyContent": "space-between",
"left": 0,
"position": "absolute",
"right": 0,
},
{
"flexDirection": "row",
},
]
}
>
<View
style={
[
{
"alignItems": "center",
"flexDirection": "row",
"justifyContent": "center",
},
{
"width": 0,
},
]
}
/>
<View
accessibilityState={
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"expanded": undefined,
"selected": undefined,
}
}
accessibilityValue={
{
"max": undefined,
"min": undefined,
"now": undefined,
"text": undefined,
}
}
accessible={true}
focusable={true}
nativeBackgroundAndroid={
{
"attribute": "selectableItemBackground",
"rippleRadius": undefined,
"type": "ThemeAttrAndroid",
}
}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
[
{
"alignItems": "center",
"alignSelf": "stretch",
"flexDirection": "row",
"justifyContent": "center",
"paddingVertical": 12,
},
{
"width": 0,
},
]
}
testID="intro-screen-notch-test$buttonDone"
>
<View
style={
{
"alignSelf": "center",
}
}
>
<View
testId="icon"
/>
</View>
</View>
</View>
</View>
</View>
</Modal>
`;
Loading
Loading