@newskit-render/core 1.44.0 → 1.48.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/__tests__/pages/[articleSlug].test.tsx +59 -18
  3. package/__tests__/pages/__snapshots__/home.test.tsx.snap +769 -1261
  4. package/components/article/Highlights.tsx +4 -33
  5. package/components/article/RelatedArticles.tsx +4 -53
  6. package/components/article/__tests__/__snapshots__/index.test.tsx.snap +53 -43
  7. package/components/section/ArticleSlice.tsx +17 -43
  8. package/components/section/CollectionBlock.tsx +38 -6
  9. package/components/section/__tests__/ArticleSlice.test.tsx +37 -51
  10. package/components/section/__tests__/CollectionBlock.test.tsx +63 -13
  11. package/components/section/__tests__/pageBlock.test.tsx +8 -4
  12. package/components/section/index.tsx +17 -12
  13. package/components/section/layouts/Lead.tsx +36 -15
  14. package/components/section/layouts/Rows.tsx +67 -0
  15. package/components/section/layouts/{SectionRow.tsx → SectionTitle.tsx} +24 -52
  16. package/components/section/layouts/__tests__/Lead.test.tsx +31 -6
  17. package/components/section/layouts/__tests__/Rows.test.tsx +28 -0
  18. package/components/section/layouts/__tests__/SectionTitle.test.tsx +36 -0
  19. package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +274 -315
  20. package/components/section/layouts/__tests__/__snapshots__/SectionTitle.test.tsx.snap +942 -0
  21. package/components/section/layouts/gridUtils.ts +12 -9
  22. package/components/section/layouts/index.tsx +2 -1
  23. package/components/section/layouts/types.ts +5 -1
  24. package/components/section/{pageBlock.ts → pageBlock.tsx} +5 -2
  25. package/components/teaser/index.tsx +7 -6
  26. package/components/teaser/teaserVariants.ts +2 -0
  27. package/components/teaser/variants/horizontal.ts +14 -0
  28. package/cypress/e2e/account/account-page.spec.js +27 -1
  29. package/cypress/e2e/account/main-api.spec.js +4 -4
  30. package/cypress/support/commands.js +2 -2
  31. package/helpers/mocks/getPageMock.ts +2 -59
  32. package/next.config.js +4 -0
  33. package/package.json +8 -7
  34. package/pages/[section]/[articleId]/[articleSlug].tsx +14 -3
  35. package/pages/api/feed.ts +19 -0
  36. package/pages/api/news-sitemap.ts +10 -2
  37. package/pages/api/sitemap.ts +10 -6
  38. package/temp/_app.tsx +209 -0
  39. package/temp/header.tsx +1 -1
  40. package/components/section/layouts/Row.tsx +0 -28
  41. package/components/section/layouts/__tests__/SectionRow.test.tsx +0 -56
  42. package/components/section/layouts/__tests__/__snapshots__/SectionRow.test.tsx.snap +0 -4542
@@ -11,7 +11,6 @@ describe('ArticleSlice', () => {
11
11
  ArticleSlice,
12
12
  {
13
13
  slice: getPageMock.page.body[0].children[0] as ArticleSliceType,
14
- collection: getPageMock.page.body[0],
15
14
  }
16
15
  )
17
16
  expect(getByTestId('SUPPLEMENT_LEAD_AND_4_STACK-Grid')).toBeInTheDocument()
@@ -25,80 +24,69 @@ describe('ArticleSlice', () => {
25
24
  ArticleSlice,
26
25
  {
27
26
  slice: getPageMock.page.body[0].children[1] as ArticleSliceType,
28
- collection: getPageMock.page.body[0],
29
27
  }
30
28
  )
31
- expect(getByTestId('SectionTitleBar')).toBeInTheDocument()
32
29
  expect(getByTestId('SECONDARY_4-Grid')).toBeInTheDocument()
33
30
  expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(4)
34
31
  expect(getAllByRole('link').length).toEqual(4)
35
32
  })
36
33
 
37
34
  test('Handle SECONDARY_4 article-block Index Page', () => {
38
- const {
39
- getByTestId,
40
- getAllByTestId,
41
- getAllByRole,
42
- queryByTestId,
43
- } = renderWithTheme(SectionContext.Provider, {
44
- value: {
45
- isIndexPage: true,
46
- },
47
- children: (
48
- <ArticleSlice
49
- slice={getPageMock.page.body[0].children[1] as ArticleSliceType}
50
- collection={getPageMock.page.body[0]}
51
- />
52
- ),
53
- })
54
- expect(queryByTestId('SectionTitleBar')).not.toBeInTheDocument()
35
+ const { getByTestId, getAllByTestId, getAllByRole } = renderWithTheme(
36
+ SectionContext.Provider,
37
+ {
38
+ value: {
39
+ isIndexPage: true,
40
+ },
41
+ children: (
42
+ <ArticleSlice
43
+ slice={getPageMock.page.body[0].children[1] as ArticleSliceType}
44
+ />
45
+ ),
46
+ }
47
+ )
48
+
55
49
  expect(getByTestId('SECONDARY_4-Grid')).toBeInTheDocument()
56
50
  expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(4)
57
51
  expect(getAllByRole('link').length).toEqual(4)
58
52
  })
59
53
 
60
- test('Handle SECONDARY_4_ODD article-block Homepage', () => {
54
+ test('Handle SECONDARY_2_AND_2 article-block Homepage', () => {
61
55
  const { getByTestId, getAllByTestId, getAllByRole } = renderWithTheme(
62
56
  ArticleSlice,
63
57
  {
64
58
  slice: getPageMock.page.body[0].children[5] as ArticleSliceType,
65
- collection: getPageMock.page.body[0],
66
59
  }
67
60
  )
68
- expect(getByTestId('SectionTitleBar')).toBeInTheDocument()
69
- expect(getByTestId('SECONDARY_4_ODD-Grid')).toBeInTheDocument()
70
- expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(4)
71
- expect(getAllByRole('link').length).toEqual(4)
61
+
62
+ expect(getByTestId('SECONDARY_2_AND_2-Grid')).toBeInTheDocument()
63
+ expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(2)
64
+ expect(getAllByRole('link').length).toEqual(2)
72
65
  })
73
66
 
74
- test('Handle SECONDARY_4_ODD article-block Index Page', () => {
75
- const {
76
- getByTestId,
77
- getAllByTestId,
78
- getAllByRole,
79
- queryByTestId,
80
- } = renderWithTheme(SectionContext.Provider, {
81
- value: {
82
- isIndexPage: true,
83
- },
84
- children: (
85
- <ArticleSlice
86
- slice={getPageMock.page.body[0].children[5] as ArticleSliceType}
87
- collection={getPageMock.page.body[0]}
88
- />
89
- ),
90
- })
91
- expect(getByTestId('SectionTitleBar')).toBeInTheDocument()
92
- expect(queryByTestId('addTopSpace')).toBeInTheDocument()
93
- expect(getByTestId('SECONDARY_4_ODD-Grid')).toBeInTheDocument()
94
- expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(4)
95
- expect(getAllByRole('link').length).toEqual(4)
67
+ test('Handle SECONDARY_2_AND_2 article-block Index Page', () => {
68
+ const { getByTestId, getAllByTestId, getAllByRole } = renderWithTheme(
69
+ SectionContext.Provider,
70
+ {
71
+ value: {
72
+ isIndexPage: true,
73
+ },
74
+ children: (
75
+ <ArticleSlice
76
+ slice={getPageMock.page.body[0].children[5] as ArticleSliceType}
77
+ />
78
+ ),
79
+ }
80
+ )
81
+
82
+ expect(getByTestId('SECONDARY_2_AND_2-Grid')).toBeInTheDocument()
83
+ expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(2)
84
+ expect(getAllByRole('link').length).toEqual(2)
96
85
  })
97
86
 
98
87
  test('Unhandled article-block', () => {
99
88
  const { getByText } = renderWithTheme(ArticleSlice, {
100
89
  slice: getPageMock.page.body[0].children[2] as ArticleSliceType,
101
- collection: getPageMock.page.body[0],
102
90
  })
103
91
  expect(getByText('Layout: LEAD_1_AND_1')).toBeInTheDocument()
104
92
  expect(getByText('test headline').closest('a')).toHaveAttribute(
@@ -114,7 +102,6 @@ describe('ArticleSlice', () => {
114
102
  test('Unhandled Layout other blocks', () => {
115
103
  const { getByText } = renderWithTheme(ArticleSlice, {
116
104
  slice: getPageMock.page.body[0].children[3] as ArticleSliceType,
117
- collection: getPageMock.page.body[0],
118
105
  })
119
106
 
120
107
  expect(getByText('Layout: LEAD_1_AND_1')).toBeInTheDocument()
@@ -128,7 +115,6 @@ describe('ArticleSlice', () => {
128
115
  ArticleSlice,
129
116
  {
130
117
  slice: getPageMock.page.body[0].children[4] as ArticleSliceType,
131
- collection: getPageMock.page.body[0],
132
118
  }
133
119
  )
134
120
 
@@ -1,33 +1,83 @@
1
+ import React from 'react'
1
2
  import CollectionBlock from '../CollectionBlock'
2
3
  import { getPageMock } from '../../../helpers/mocks'
4
+ import { CollectionBlock as Collection } from '../../../helpers/global-types'
5
+ import { renderWithTheme } from '../../../helpers/test-utils'
6
+ import { SectionContext } from '../SectionContext'
3
7
 
4
- jest.mock('../ArticleSlice', () => {
5
- return jest.fn(() => {})
6
- })
8
+ jest.mock('../ArticleSlice', () => () => <div data-testid="article-slice" />)
7
9
 
8
10
  describe('CollectionBlock', () => {
9
- test('returns slice', () => {
10
- expect(
11
- CollectionBlock(getPageMock.page.body[0])[0].props.slice.name
12
- ).toEqual('SUPPLEMENT_LEAD_AND_4_STACK')
13
- expect(
14
- CollectionBlock(getPageMock.page.body[0])[0].props.collection.id
15
- ).toEqual('123a')
11
+ test('renders section title with articles', () => {
12
+ const { getByTestId, getAllByTestId } = renderWithTheme(
13
+ SectionContext.Provider,
14
+ {
15
+ value: {
16
+ isIndexPage: false,
17
+ },
18
+ children: (
19
+ <CollectionBlock collection={getPageMock.page.body[0]} index={1} />
20
+ ),
21
+ }
22
+ )
23
+
24
+ expect(getByTestId('SectionTitleBar')).toBeInTheDocument()
25
+ expect(getAllByTestId('article-slice').length).toEqual(6)
26
+ })
27
+
28
+ test('should not render section title', () => {
29
+ const { queryByTestId } = renderWithTheme(SectionContext.Provider, {
30
+ value: {
31
+ isIndexPage: true,
32
+ },
33
+ children: (
34
+ <CollectionBlock collection={getPageMock.page.body[0]} index={1} />
35
+ ),
36
+ })
37
+
38
+ expect(queryByTestId('SectionTitleBar')).not.toBeInTheDocument()
39
+ })
40
+
41
+ test('should not render section title when index is 0', () => {
42
+ const { queryByTestId } = renderWithTheme(SectionContext.Provider, {
43
+ value: {
44
+ isIndexPage: false,
45
+ },
46
+ children: (
47
+ <CollectionBlock collection={getPageMock.page.body[0]} index={0} />
48
+ ),
49
+ })
50
+
51
+ expect(queryByTestId('SectionTitleBar')).not.toBeInTheDocument()
16
52
  })
53
+
17
54
  test('should handle topic-author-slice', () => {
18
55
  const topic = {
19
56
  ...getPageMock.page.body[0],
20
57
  }
21
58
  topic.children[0].type = 'topic-author-slice'
22
59
  topic.children[1].type = 'topic-author-slice'
23
- expect(CollectionBlock(topic)[0]).toEqual(null)
60
+
61
+ const { getAllByTestId } = renderWithTheme(CollectionBlock, {
62
+ collection: topic as Collection,
63
+ index: 1,
64
+ })
65
+
66
+ expect(getAllByTestId('article-slice').length).toEqual(4)
24
67
  })
25
- test('should handle unknown slice type', () => {
68
+
69
+ test('should handle topic-author-slice', () => {
26
70
  const topic = {
27
71
  ...getPageMock.page.body[0],
28
72
  }
29
73
  topic.children[0].type = 'unknown'
30
74
  topic.children[1].type = 'unknown'
31
- expect(CollectionBlock(topic)[0]).toEqual(null)
75
+
76
+ const { getAllByTestId } = renderWithTheme(CollectionBlock, {
77
+ collection: topic as Collection,
78
+ index: 1,
79
+ })
80
+
81
+ expect(getAllByTestId('article-slice').length).toEqual(4)
32
82
  })
33
83
  })
@@ -1,14 +1,18 @@
1
+ import React from 'react'
1
2
  import pageBlock from '../pageBlock'
2
3
  import { getPageMock } from '../../../helpers/mocks'
4
+ import CollectionBlock from '../CollectionBlock'
3
5
 
4
- jest.mock('../CollectionBlock', () => {
5
- return jest.fn(() => 'is Collection')
6
- })
6
+ jest.mock('../CollectionBlock', () => () => (
7
+ <div data-testid="collectionBlock" />
8
+ ))
7
9
 
8
10
  describe('test pageBlock', () => {
9
11
  const collection = getPageMock.page.body[0]
10
12
  test('pageBlock returns CollectionBlock', () => {
11
- expect(pageBlock('collection')(collection)).toBe('is Collection')
13
+ expect(pageBlock('collection')(collection, 0)).toStrictEqual(
14
+ <CollectionBlock collection={collection} index={0} />
15
+ )
12
16
  })
13
17
 
14
18
  test('pageBlock returns null', () => {
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { Cell } from 'newskit'
2
+ import { Block, Cell } from 'newskit'
3
3
  import { UserData } from '@newskit-render/my-account'
4
4
  import { Page } from '../../helpers/global-types'
5
5
  import Layout from '../layout'
@@ -17,16 +17,21 @@ const SectionPage: React.FC<{
17
17
  page: Page
18
18
  isIndexPage?: boolean
19
19
  user?: UserData
20
- }> = ({ page, user, isIndexPage = false }) => (
21
- <SectionContext.Provider value={{ isIndexPage }}>
22
- <Layout dataTestId="SectionGrid" gridOverride={gridOverride} user={user}>
23
- <Cell xs={12} md={10} mdOffset={1} data-testid="SectionCell">
24
- {isIndexPage && <SectionTitleBar title={page.title} />}
25
- {Array.isArray(page.body) &&
26
- page.body.map((block) => pageBlock(block.type as string)(block))}
27
- </Cell>
28
- </Layout>
29
- </SectionContext.Provider>
30
- )
20
+ }> = ({ page, user, isIndexPage = false }) => {
21
+ return (
22
+ <SectionContext.Provider value={{ isIndexPage }}>
23
+ <Layout dataTestId="SectionGrid" gridOverride={gridOverride} user={user}>
24
+ <Cell xs={12} md={10} mdOffset={1} data-testid="SectionCell">
25
+ <Block spaceStack="space070" />
26
+ {isIndexPage && <SectionTitleBar title={page.title} />}
27
+ {Array.isArray(page.body) &&
28
+ page.body.map((block, i) =>
29
+ pageBlock(block.type as string)(block, i)
30
+ )}
31
+ </Cell>
32
+ </Layout>
33
+ </SectionContext.Provider>
34
+ )
35
+ }
31
36
 
32
37
  export default SectionPage
@@ -1,23 +1,44 @@
1
1
  import React from 'react'
2
- import { Grid, Cell } from 'newskit'
2
+ import { GridLayout, Block } from 'newskit'
3
3
  import { outerGridOverride, innerGridOverride } from './gridUtils'
4
4
  import { getBlock } from './Block'
5
5
  import { LayoutProps } from './types'
6
6
 
7
7
  export const Lead: React.FC<LayoutProps> = ({ slice }) => (
8
- <Grid {...outerGridOverride} data-testid={`${slice.name}-Grid`}>
9
- <Cell xs={12} xl={8} data-testid="featureVerticalCell">
8
+ <GridLayout
9
+ {...outerGridOverride}
10
+ columns={{ lg: '2fr 1fr' }}
11
+ columnGap="space050"
12
+ data-testid={`${slice.name}-Grid`}
13
+ >
14
+ <Block data-testid="featureVerticalCell">
10
15
  {getBlock(slice.children[0], 'featureVertical')}
11
- </Cell>
12
- <Cell xs={12} xl={4} data-testid="titleTeaserVerticalsCell">
13
- <Grid {...innerGridOverride} data-testid={`${slice.name}-InnerGrid`}>
14
- <Cell xs={12} md={6} xl={12} data-testid="titleVerticalCell-1">
15
- {getBlock(slice.children[1], 'titleVertical')}
16
- </Cell>
17
- <Cell xs={12} md={6} xl={12} data-testid="titleVerticalCell-2">
18
- {getBlock(slice.children[2], 'titleVertical')}
19
- </Cell>
20
- </Grid>
21
- </Cell>
22
- </Grid>
16
+ </Block>
17
+ <GridLayout
18
+ columnGap={{ md: '20px' }}
19
+ columns={{ xs: '1fr', md: '1fr 1fr', lg: '1fr' }}
20
+ justifyContent={{ lg: 'stretch' }}
21
+ alignContent={{ lg: 'space-between' }}
22
+ overrides={{ height: '100%' }}
23
+ {...innerGridOverride}
24
+ >
25
+ {slice.children.slice(1).map((block, i) => {
26
+ return (
27
+ <Block
28
+ /* eslint-disable-next-line */
29
+ key={`titleVerticalCell-${i}`}
30
+ data-testid={`titleVerticalCell-${i}`}
31
+ >
32
+ {getBlock(block, 'horizontal')}
33
+ </Block>
34
+ )
35
+ })}
36
+ </GridLayout>
37
+ </GridLayout>
38
+ )
39
+
40
+ export const LeadFullWidth: React.FC<LayoutProps> = ({ slice }) => (
41
+ <Block data-testid={`${slice.name}-Grid`}>
42
+ {getBlock(slice.children[0], 'featureVertical')}
43
+ </Block>
23
44
  )
@@ -0,0 +1,67 @@
1
+ import React from 'react'
2
+ import { Block, GridLayout } from 'newskit'
3
+ import { LayoutProps } from './types'
4
+ import { outerGridOverride } from './gridUtils'
5
+ import { getBlock } from './Block'
6
+
7
+ export const BasicRow: React.FC<LayoutProps> = ({
8
+ slice,
9
+ colums,
10
+ variant = 'titleTeaserVertical',
11
+ }) => (
12
+ <GridLayout
13
+ columns={colums}
14
+ columnGap="space050"
15
+ data-testid={`${slice.name}-Grid`}
16
+ {...outerGridOverride}
17
+ >
18
+ {slice.children.map((block, i) => (
19
+ <Block
20
+ key={('article' in block && block.article.id) || i}
21
+ data-testid={`titleTeaserVertical-${i}`}
22
+ >
23
+ {getBlock(block, variant)}
24
+ </Block>
25
+ ))}
26
+ </GridLayout>
27
+ )
28
+
29
+ export const Row3: React.FC<LayoutProps> = ({ slice }) => (
30
+ <GridLayout
31
+ areas={{
32
+ xs: `
33
+ "A"
34
+ "B"
35
+ "C"
36
+ `,
37
+ md: `
38
+ "A B"
39
+ "A C"
40
+ `,
41
+ lg: `
42
+ "A B C"
43
+ `,
44
+ }}
45
+ rowGap={{ xs: 'space010', md: 'space040' }}
46
+ columnGap={{ md: 'space050', lg: 'space050' }}
47
+ data-testid={`${slice.name}-Grid`}
48
+ >
49
+ {
50
+ (Areas) =>
51
+ Object.entries(Areas).map((Area, i) => {
52
+ const AreaComp = Area[1]
53
+ const block = slice.children[i]
54
+
55
+ return (
56
+ <AreaComp
57
+ key={('article' in block && block.article.id) || i}
58
+ data-testid={`titleTeaserVertical-${i}`}
59
+ >
60
+ {getBlock(block, 'horizontal')}
61
+ </AreaComp>
62
+ )
63
+ })
64
+ /* eslint-disable-next-line */
65
+ }
66
+ </GridLayout>
67
+ )
@@ -1,33 +1,9 @@
1
1
  import React from 'react'
2
- import {
3
- styled,
4
- getColorCssFromTheme,
5
- Block,
6
- Divider,
7
- BlockProps,
8
- } from 'newskit'
9
2
  import { NextLink } from '@newskit-render/shared-components'
3
+ import { Block, Divider, getColorCssFromTheme, styled } from 'newskit'
10
4
  import { LayoutProps } from './types'
11
- import { CollectionBlock } from '../../../helpers/global-types'
12
5
  import StyledIconFilledChevronRight from '../../common/icons/StyledIconFilledChevronRight'
13
6
  import SectionTitleBar from '../../common/SectionTitleBar'
14
- import Row from './Row'
15
-
16
- type StyledBackground = BlockProps & {
17
- isDarkBackground?: boolean
18
- }
19
-
20
- const StyledBackgroundBlock = styled(Block)<StyledBackground>`
21
- background: ${(props) =>
22
- props.isDarkBackground
23
- ? getColorCssFromTheme('color', 'interface030')
24
- : getColorCssFromTheme('color', 'transparent')};
25
- `
26
-
27
- const StyledDivider = styled(Divider)`
28
- ${getColorCssFromTheme('background', 'transparent')};
29
- ${getColorCssFromTheme('borderColor', 'transparent')};
30
- `
31
7
 
32
8
  const link = (href: string, stylePreset?: string) => (
33
9
  <NextLink
@@ -44,42 +20,38 @@ const link = (href: string, stylePreset?: string) => (
44
20
  </NextLink>
45
21
  )
46
22
 
47
- type SectionRowProps = {
48
- collection?: CollectionBlock
49
- isDarkBackground?: boolean
50
- showTitle?: boolean
51
- addTopSpace?: boolean
23
+ const StyledDivider = styled(Divider)`
24
+ ${getColorCssFromTheme('background', 'transparent')};
25
+ ${getColorCssFromTheme('borderColor', 'transparent')};
26
+ `
27
+
28
+ type SectionTitleProps = {
29
+ title: string
52
30
  titleBarStylePreset?: string
53
31
  titleBarColour?: string
32
+ addTopSpace?: boolean
54
33
  } & LayoutProps
55
34
 
56
- export const SectionRow: React.FC<SectionRowProps> = ({
57
- slice,
58
- collection,
35
+ export const SectionTitle: React.FC<SectionTitleProps> = ({
36
+ title,
59
37
  sectionURL,
60
- isDarkBackground,
61
- showTitle = true,
62
- addTopSpace,
63
38
  titleBarStylePreset,
64
39
  titleBarColour,
65
- }) => (
66
- <StyledBackgroundBlock isDarkBackground={isDarkBackground}>
67
- {addTopSpace && (
68
- <Block spaceStack="space060" data-testid="addTopSpace">
69
- <StyledDivider />
70
- </Block>
71
- )}
72
- {showTitle && (
40
+ addTopSpace,
41
+ }) => {
42
+ return (
43
+ <>
44
+ {addTopSpace && (
45
+ <Block spaceStack="space060" data-testid="addTopSpace">
46
+ <StyledDivider />
47
+ </Block>
48
+ )}
73
49
  <SectionTitleBar
74
- title={collection?.title as string}
50
+ title={title}
75
51
  actionItem={() => link(sectionURL as string, titleBarStylePreset)}
76
52
  stylePreset={titleBarStylePreset}
77
53
  colour={titleBarColour}
78
54
  />
79
- )}
80
- <Block spaceStack={showTitle ? 'space070' : 'space000'}>
81
- <Row slice={slice} />
82
- </Block>
83
- <StyledDivider />
84
- </StyledBackgroundBlock>
85
- )
55
+ </>
56
+ )
57
+ }
@@ -1,12 +1,37 @@
1
1
  import { renderWithTheme } from '../../../../helpers/test-utils'
2
- import { Lead } from '../Lead'
2
+ import { Lead, LeadFullWidth } from '../Lead'
3
3
  import { getPageMock } from '../../../../helpers/mocks'
4
4
  import { ArticleSlice } from '../../../../helpers/global-types'
5
5
 
6
- test('Lead', () => {
7
- const { asFragment } = renderWithTheme(Lead, {
8
- slice: getPageMock.page.body[0].children[0] as ArticleSlice,
9
- sectionURL: getPageMock.page.body[0].link.url,
6
+ describe('Lead', () => {
7
+ test('should render Lead', () => {
8
+ const { asFragment } = renderWithTheme(Lead, {
9
+ slice: getPageMock.page.body[0].children[0] as ArticleSlice,
10
+ })
11
+ expect(asFragment()).toMatchSnapshot()
12
+ })
13
+
14
+ test('should render Lead with cells', () => {
15
+ const { getAllByTestId, queryByTestId } = renderWithTheme(Lead, {
16
+ slice: getPageMock.page.body[0].children[0] as ArticleSlice,
17
+ })
18
+
19
+ expect(
20
+ queryByTestId('SUPPLEMENT_LEAD_AND_4_STACK-Grid')
21
+ ).toBeInTheDocument()
22
+ expect(queryByTestId('featureVerticalCell')).toBeInTheDocument()
23
+ expect(getAllByTestId(/titleVerticalCell-/).length).toEqual(2)
24
+ })
25
+ })
26
+
27
+ describe('Lead full width', () => {
28
+ test('should render Lead full width', () => {
29
+ const { queryByTestId } = renderWithTheme(LeadFullWidth, {
30
+ slice: getPageMock.page.body[0].children[0] as ArticleSlice,
31
+ })
32
+
33
+ expect(
34
+ queryByTestId('SUPPLEMENT_LEAD_AND_4_STACK-Grid')
35
+ ).toBeInTheDocument()
10
36
  })
11
- expect(asFragment()).toMatchSnapshot()
12
37
  })
@@ -0,0 +1,28 @@
1
+ import { renderWithTheme } from '../../../../helpers/test-utils'
2
+ import { BasicRow, Row3 } from '../Rows'
3
+ import { getPageMock } from '../../../../helpers/mocks'
4
+ import { ArticleSlice } from '../../../../helpers/global-types'
5
+
6
+ describe('Rows', () => {
7
+ test('should render a row with 2 columns', () => {
8
+ const slice = {
9
+ ...getPageMock.page.body[0].children[0],
10
+ children: getPageMock.page.body[0].children[0].children.slice(0, 2),
11
+ }
12
+ const { getAllByTestId } = renderWithTheme(BasicRow, {
13
+ slice: slice as ArticleSlice,
14
+ colums: { xs: '1fr', md: '1fr 1fr' },
15
+ })
16
+
17
+ expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(2)
18
+ })
19
+
20
+ test('should render a row with 3 columns', () => {
21
+ const { getAllByTestId } = renderWithTheme(Row3, {
22
+ slice: getPageMock.page.body[0].children[0] as ArticleSlice,
23
+ colums: { xs: '1fr', md: '1fr 1fr' },
24
+ })
25
+
26
+ expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(3)
27
+ })
28
+ })
@@ -0,0 +1,36 @@
1
+ import { renderWithTheme } from '../../../../helpers/test-utils'
2
+ import { SectionTitle } from '../SectionTitle'
3
+ import { getPageMock } from '../../../../helpers/mocks'
4
+ import { ArticleSlice } from '../../../../helpers/global-types'
5
+
6
+ describe('SectionTitle', () => {
7
+ test('SectionTitle with title', () => {
8
+ const { asFragment } = renderWithTheme(SectionTitle, {
9
+ slice: getPageMock.page.body[0].children[1] as ArticleSlice,
10
+ sectionURL: getPageMock.page.body[0].link.url,
11
+ title: getPageMock.page.body[0].title,
12
+ })
13
+ expect(asFragment()).toMatchSnapshot()
14
+ })
15
+
16
+ test('SectionTitle without extra space', () => {
17
+ const { asFragment } = renderWithTheme(SectionTitle, {
18
+ slice: getPageMock.page.body[0].children[1] as ArticleSlice,
19
+ sectionURL: getPageMock.page.body[0].link.url,
20
+ title: getPageMock.page.body[0].title,
21
+ addTopSpace: true,
22
+ })
23
+ expect(asFragment()).toMatchSnapshot()
24
+ })
25
+
26
+ test('SectionTitle alternative titlebar', () => {
27
+ const { asFragment } = renderWithTheme(SectionTitle, {
28
+ slice: getPageMock.page.body[0].children[1] as ArticleSlice,
29
+ sectionURL: getPageMock.page.body[0].link.url,
30
+ title: getPageMock.page.body[0].title,
31
+ titleBarStylePreset: 'inkContrast',
32
+ titleBarColour: 'transparent',
33
+ })
34
+ expect(asFragment()).toMatchSnapshot()
35
+ })
36
+ })