@newskit-render/core 0.131.1 → 0.138.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.
@@ -3,19 +3,24 @@ import SectionPage from '../../components/section'
3
3
  import { renderWithTheme } from '../../helpers/test-utils'
4
4
  import { getPageMock } from '../../helpers/mocks'
5
5
 
6
- jest.mock('../../helpers/createApolloClient', () => () => ({
7
- query: jest.fn(() =>
8
- Promise.resolve({
9
- data: {
10
- page: {
11
- data: {
12
- id: '123',
13
- title: 'Test title',
6
+ jest.mock('@newskit-render/api', () => ({
7
+ ClientTypes: { nkapi: 'nkapi' },
8
+ createApolloClient: jest.fn().mockImplementation(() => {
9
+ return Promise.resolve({
10
+ query: jest.fn().mockResolvedValueOnce({
11
+ data: {
12
+ page: {
13
+ data: {
14
+ id: '123',
15
+ title: 'Test title',
16
+ },
14
17
  },
15
18
  },
16
- },
19
+ }),
17
20
  })
18
- ),
21
+ }),
22
+ sessionParser: jest.fn(),
23
+ getMainSession: jest.fn(),
19
24
  }))
20
25
 
21
26
  jest.mock('cross-fetch', () =>
@@ -44,8 +49,10 @@ describe('getServerSideProps', () => {
44
49
  expect(asFragment()).toMatchSnapshot()
45
50
  })
46
51
  test('should call newskit api and return Page data', async () => {
52
+ const setHeaderMock = jest.fn()
47
53
  const response = await getServerSideProps({
48
54
  req: { headers: { cookie: 'session-cookie' } },
55
+ res: { setHeader: setHeaderMock },
49
56
  })
50
57
  expect(response).toEqual(
51
58
  expect.objectContaining({
@@ -62,5 +69,10 @@ describe('getServerSideProps', () => {
62
69
  },
63
70
  })
64
71
  )
72
+
73
+ expect(setHeaderMock).toHaveBeenCalledWith(
74
+ 'Cache-Control',
75
+ 'public, s-maxage=10, stale-while-revalidate=59'
76
+ )
65
77
  })
66
78
  })
@@ -4,13 +4,13 @@ import {
4
4
  Cell,
5
5
  Image,
6
6
  TextBlock,
7
- LinkStandalone,
8
7
  IconFilledKeyboardArrowLeft,
9
8
  styled,
10
9
  getMediaQueryFromTheme,
11
10
  getSizingCssFromTheme,
12
11
  } from 'newskit'
13
12
  import Head from 'next/head'
13
+ import { NextLink } from '@newskit-render/shared-components'
14
14
  import Layout from '../layout'
15
15
  import { headerSize } from '../header'
16
16
 
@@ -46,9 +46,12 @@ const StyledMain = styled.main`
46
46
  max-width: 440px;
47
47
  }
48
48
  `
49
+ const paddingCB = (size: string) => ({
50
+ padding: `${size} 0`,
51
+ })
49
52
 
50
- const StyledLinkStandalone = styled(LinkStandalone)`
51
- padding: 14px 0;
53
+ const StyledLink = styled(NextLink)`
54
+ ${getSizingCssFromTheme(paddingCB, 'sizing030')}
52
55
  `
53
56
 
54
57
  const gridOverride = {
@@ -101,7 +104,8 @@ const FourOhFour = () => (
101
104
  <Block
102
105
  spaceStack={{ xs: 'space070', sm: 'space080', md: 'space090' }}
103
106
  >
104
- <StyledLinkStandalone
107
+ <StyledLink
108
+ type="standalone"
105
109
  data-test-id="StyledLinkStandalone"
106
110
  href="/"
107
111
  external={false}
@@ -114,7 +118,7 @@ const FourOhFour = () => (
114
118
  }}
115
119
  />
116
120
  Back to ...
117
- </StyledLinkStandalone>
121
+ </StyledLink>
118
122
  </Block>
119
123
  </StyledMain>
120
124
  </Cell>