-
Notifications
You must be signed in to change notification settings - Fork 577
/
ArticleScreen.tests.tsx
68 lines (58 loc) · 2.25 KB
/
ArticleScreen.tests.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { Screen } from "@artsy/palette-mobile"
import { screen, waitForElementToBeRemoved } from "@testing-library/react-native"
import { ArticleScreen } from "app/Scenes/Article/ArticleScreen"
import { ArticleBody } from "app/Scenes/Article/Components/ArticleBody"
import { ArticleRelatedArticlesRail } from "app/Scenes/Article/Components/ArticleRelatedArticlesRail"
import { ArticleWebViewScreen } from "app/Scenes/Article/Components/ArticleWebViewScreen"
import { setupTestWrapper } from "app/utils/tests/setupTestWrapper"
describe("ArticleScreen", () => {
const { renderWithRelay } = setupTestWrapper({
Component: ArticleScreen,
variables: {
slug: "some-id",
},
})
it("renders standard article", async () => {
renderWithRelay({
Query: () => ({
article: {
title: "Article Title",
layout: "STANDARD",
},
}),
})
await waitForElementToBeRemoved(() => screen.getByTestId("ArticleScreenPlaceholder"))
expect(screen.queryByText("Article Title")).toBeOnTheScreen()
expect(screen.UNSAFE_getByType(Screen.AnimatedHeader)).toBeOnTheScreen()
expect(screen.UNSAFE_getByType(ArticleBody)).toBeOnTheScreen()
expect(screen.UNSAFE_getByType(ArticleRelatedArticlesRail)).toBeOnTheScreen()
})
it("renders featured article", async () => {
renderWithRelay({
Query: () => ({
article: {
title: "Article Title",
layout: "FEATURE",
},
}),
})
await waitForElementToBeRemoved(() => screen.getByTestId("ArticleScreenPlaceholder"))
expect(screen.queryByText("Article Title")).toBeOnTheScreen()
expect(screen.UNSAFE_getByType(Screen.FloatingHeader)).toBeOnTheScreen()
expect(screen.UNSAFE_getByType(ArticleBody)).toBeOnTheScreen()
expect(screen.UNSAFE_getByType(ArticleRelatedArticlesRail)).toBeOnTheScreen()
})
it("redirects to webview if not standard or feature", async () => {
renderWithRelay({
Query: () => ({
article: {
internalID: "foo",
title: "Article Title",
layout: "VIDEO",
},
}),
})
await waitForElementToBeRemoved(() => screen.getByTestId("ArticleScreenPlaceholder"))
expect(screen.UNSAFE_getByType(ArticleWebViewScreen)).toBeOnTheScreen()
})
})