@financial-times/dotcom-ui-layout 9.0.0-beta.8 → 9.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/dotcom-ui-layout",
3
- "version": "9.0.0-beta.8",
3
+ "version": "9.0.1",
4
4
  "description": "",
5
5
  "main": "component.js",
6
6
  "browser": "browser.js",
@@ -22,15 +22,16 @@
22
22
  "author": "",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@financial-times/dotcom-types-navigation": "^9.0.0-beta.8",
26
- "@financial-times/dotcom-ui-base-styles": "^9.0.0-beta.8",
27
- "@financial-times/dotcom-ui-footer": "^9.0.0-beta.8",
28
- "@financial-times/dotcom-ui-header": "^9.0.0-beta.8",
25
+ "@financial-times/dotcom-types-navigation": "^9.0.1",
26
+ "@financial-times/dotcom-ui-base-styles": "^9.0.1",
27
+ "@financial-times/dotcom-ui-footer": "^9.0.1",
28
+ "@financial-times/dotcom-ui-header": "^9.0.1",
29
29
  "focus-visible": "^5.0.0",
30
30
  "n-ui-foundations": "^9.0.0"
31
31
  },
32
32
  "peerDependencies": {
33
- "react": "16.x || 17.x"
33
+ "react": "17.x || 18.x",
34
+ "react-dom": "17.x || 18.x"
34
35
  },
35
36
  "engines": {
36
37
  "node": "16.x || 18.x",
@@ -53,7 +54,6 @@
53
54
  "extends": "../../package.json"
54
55
  },
55
56
  "devDependencies": {
56
- "check-engine": "^1.10.1",
57
- "react": "^16.8.6"
57
+ "check-engine": "^1.10.1"
58
58
  }
59
59
  }
@@ -1,227 +1,233 @@
1
1
  /**
2
2
  * @jest-environment jsdom
3
3
  */
4
- import 'jest-enzyme'
5
4
  import React from 'react'
6
- import { shallow } from 'enzyme'
5
+ import { render } from '@testing-library/react'
7
6
 
8
7
  import { Layout as Subject } from '../Layout'
9
- import { Header, Drawer, LogoOnly, NoOutboundLinksHeader } from '@financial-times/dotcom-ui-header'
10
- import { Footer, LegalFooter } from '@financial-times/dotcom-ui-footer'
11
8
 
12
- describe('dotcom-ui-layout/src/components/Layout', () => {
13
- const result = shallow(<Subject />)
9
+ jest.mock('@financial-times/dotcom-ui-header', () => ({
10
+ Header: () => <div>Header mock</div>,
11
+ Drawer: () => <div>Drawer mock</div>,
12
+ LogoOnly: () => <div>LogoOnly mock</div>,
13
+ NoOutboundLinksHeader: () => <div>NoOutboundLinksHeader mock</div>
14
+ }))
15
+
16
+ jest.mock('@financial-times/dotcom-ui-footer', () => ({
17
+ Footer: () => <div>Footer mock</div>,
18
+ LegalFooter: () => <div>LegalFooter mock</div>
19
+ }))
14
20
 
21
+ describe('dotcom-ui-layout/src/components/Layout', () => {
15
22
  it('renders skip links to page landmarks', () => {
16
- expect(result.find('a[href="#site-navigation"]')).toHaveText('Skip to navigation')
17
- expect(result.find('a[href="#site-content"]')).toHaveText('Skip to content')
18
- expect(result.find('a[href="#site-footer"]')).toHaveText('Skip to footer')
19
- })
23
+ const { container } = render(<Subject />)
24
+
25
+ const skipToNavigationLink = container.querySelector('a[href="#site-navigation"]')
26
+ const skipToContentLink = container.querySelector('a[href="#site-content"]')
27
+ const skipToFooterLink = container.querySelector('a[href="#site-footer"]')
20
28
 
21
- it('renders the header and drawer components', () => {
22
- expect(result.find(Header)).toExist()
23
- expect(result.find(Drawer)).toExist()
29
+ expect(skipToNavigationLink?.innerHTML).toContain('Skip to navigation')
30
+ expect(skipToContentLink?.innerHTML).toContain('Skip to content')
31
+ expect(skipToFooterLink?.innerHTML).toContain('Skip to footer')
24
32
  })
25
33
 
26
- it('renders the footer component', () => {
27
- expect(result.find(Footer)).toExist()
34
+ it('renders the header, drawer & footer components', () => {
35
+ const { container } = render(<Subject />)
36
+
37
+ expect(container.innerHTML).toContain('Header mock')
38
+ expect(container.innerHTML).toContain('Drawer mock')
39
+ expect(container.innerHTML).toContain('Footer mock')
28
40
  })
41
+ })
42
+
43
+ describe('header variations', () => {
44
+ describe('with the simple variant', () => {
45
+ it('renders the header component', () => {
46
+ const { container } = render(<Subject headerVariant={'simple' as any} />)
47
+
48
+ expect(container.innerHTML).toContain('Header mock')
49
+ })
50
+
51
+ it('renders the drawer component', () => {
52
+ const { container } = render(<Subject headerVariant={'simple' as any} />)
29
53
 
30
- describe('header variations', () => {
31
- describe('with the simple variant', () => {
32
- let result
54
+ expect(container.innerHTML).toContain('Drawer mock')
55
+ })
33
56
 
34
- beforeAll(() => {
35
- result = shallow(<Subject headerVariant={'simple' as any} />)
36
- })
57
+ it('renders the navigation skip link', () => {
58
+ const { container } = render(<Subject headerVariant={'simple' as any} />)
37
59
 
38
- it('renders the header component', () => {
39
- expect(result.find(Header)).toExist()
40
- })
60
+ expect(container.querySelector('a[href="#site-navigation"]')).not.toBeNull()
61
+ })
62
+ })
41
63
 
42
- it('renders the drawer component', () => {
43
- expect(result.find(Drawer)).toExist()
44
- })
64
+ describe('with the large-logo variant', () => {
65
+ it('renders the header component', () => {
66
+ const { container } = render(<Subject headerVariant={'large-logo' as any} />)
45
67
 
46
- it('renders the navigation skip link', () => {
47
- expect(result.find('a[href="#site-navigation"]')).toExist()
48
- })
68
+ expect(container.innerHTML).toContain('Header mock')
49
69
  })
50
70
 
51
- describe('with the large-logo variant', () => {
52
- let result
71
+ it('renders the drawer component', () => {
72
+ const { container } = render(<Subject headerVariant={'large-logo' as any} />)
53
73
 
54
- beforeAll(() => {
55
- result = shallow(<Subject headerVariant={'large-logo' as any} />)
56
- })
74
+ expect(container.innerHTML).toContain('Drawer mock')
75
+ })
57
76
 
58
- it('renders the header component', () => {
59
- expect(result.find(Header)).toExist()
60
- })
77
+ it('renders the navigation skip link', () => {
78
+ const { container } = render(<Subject headerVariant={'large-logo' as any} />)
61
79
 
62
- it('renders the drawer component', () => {
63
- expect(result.find(Drawer)).toExist()
64
- })
80
+ expect(container.querySelector('a[href="#site-navigation"]')).not.toBeNull()
81
+ })
82
+ })
65
83
 
66
- it('renders the navigation skip link', () => {
67
- expect(result.find('a[href="#site-navigation"]')).toExist()
68
- })
84
+ describe('with the logo-only variant', () => {
85
+ it('renders the logo only header component', () => {
86
+ const { container } = render(<Subject headerVariant={'logo-only' as any} />)
87
+
88
+ expect(container.innerHTML).toContain('LogoOnly mock')
69
89
  })
70
90
 
71
- describe('with the logo-only variant', () => {
72
- let result
91
+ it('does not render the drawer component', () => {
92
+ const { container } = render(<Subject headerVariant={'logo-only' as any} />)
93
+
94
+ expect(container.innerHTML).not.toContain('Drawer mock')
95
+ })
73
96
 
74
- beforeAll(() => {
75
- result = shallow(<Subject headerVariant={'logo-only' as any} />)
76
- })
97
+ it('does not render the navigation skip link', () => {
98
+ const { container } = render(<Subject headerVariant={'logo-only' as any} />)
77
99
 
78
- it('renders the logo only header component', () => {
79
- expect(result.find(LogoOnly)).toExist()
80
- })
100
+ expect(container.querySelector('a[href="#site-navigation"]')).toBeNull()
101
+ })
102
+ })
81
103
 
82
- it('does not render the drawer component', () => {
83
- expect(result.find(Drawer)).not.toExist()
84
- })
104
+ describe('with the no-outbound-links variant', () => {
105
+ it('renders the no-outbound-links header component', () => {
106
+ const { container } = render(<Subject headerVariant={'no-outbound-links' as any} />)
85
107
 
86
- it('does not render the navigation skip link', () => {
87
- expect(result.find('a[href="#site-navigation"]')).not.toExist()
88
- })
108
+ expect(container.innerHTML).toContain('NoOutboundLinksHeader mock')
89
109
  })
90
110
 
91
- describe('with the no-outbound-links variant', () => {
92
- let result
111
+ it('does not render the drawer component', () => {
112
+ const { container } = render(<Subject headerVariant={'no-outbound-links' as any} />)
93
113
 
94
- beforeAll(() => {
95
- result = shallow(<Subject headerVariant={'no-outbound-links' as any} />)
96
- })
114
+ expect(container.innerHTML).not.toContain('Drawer mock')
115
+ })
116
+
117
+ it('does not render the navigation skip link', () => {
118
+ const { container } = render(<Subject headerVariant={'no-outbound-links' as any} />)
97
119
 
98
- it('renders the no-outbound-links header component', () => {
99
- expect(result.find(NoOutboundLinksHeader)).toExist()
100
- })
120
+ expect(container.querySelector('a[href="#site-navigation"]')).toBeNull()
121
+ })
122
+ })
101
123
 
102
- it('does not render the drawer component', () => {
103
- expect(result.find(Drawer)).not.toExist()
104
- })
124
+ describe('with the header disabled', () => {
125
+ it('does not render the header component', () => {
126
+ const { container } = render(<Subject headerVariant={false} />)
105
127
 
106
- it('does not render the navigation skip link', () => {
107
- expect(result.find('a[href="#site-navigation"]')).not.toExist()
108
- })
128
+ expect(container.innerHTML).not.toContain('Header mock')
109
129
  })
110
130
 
111
- describe('with the header disabled', () => {
112
- let result
131
+ it('does not render the drawer component', () => {
132
+ const { container } = render(<Subject headerVariant={false} />)
113
133
 
114
- beforeAll(() => {
115
- result = shallow(<Subject headerVariant={false} />)
116
- })
134
+ expect(container.innerHTML).not.toContain('Drawer mock')
135
+ })
117
136
 
118
- it('does not render the header component', () => {
119
- expect(result.find(Header)).not.toExist()
120
- })
137
+ it('does not render the navigation skip link', () => {
138
+ const { container } = render(<Subject headerVariant={false} />)
121
139
 
122
- it('does not render the drawer component', () => {
123
- expect(result.find(Drawer)).not.toExist()
124
- })
140
+ expect(container.querySelector('a[href="#site-navigation"]')).toBeNull()
141
+ })
142
+ })
143
+
144
+ describe('with a custom header component', () => {
145
+ it('renders the given component', () => {
146
+ const { container } = render(<Subject headerComponent={<header>My custom header</header>} />)
125
147
 
126
- it('does not render the navigation skip link', () => {
127
- expect(result.find('a[href="#site-navigation"]')).not.toExist()
128
- })
148
+ expect(container.innerHTML).toContain('My custom header')
129
149
  })
130
150
 
131
- describe('with a custom header component', () => {
132
- let result
151
+ it('does not render the header component', () => {
152
+ const { container } = render(<Subject headerComponent={<header>My custom header</header>} />)
133
153
 
134
- beforeAll(() => {
135
- const customHeader = <header>My custom header</header>
136
- result = shallow(<Subject headerComponent={customHeader} />)
137
- })
154
+ expect(container.innerHTML).not.toContain('Header mock')
155
+ })
138
156
 
139
- it('renders the given component', () => {
140
- expect(result.find('header')).toHaveText('My custom header')
141
- })
157
+ it('does not render the drawer component', () => {
158
+ const { container } = render(<Subject headerComponent={<header>My custom header</header>} />)
142
159
 
143
- it('does not render the header component', () => {
144
- expect(result.find(Header)).not.toExist()
145
- })
160
+ expect(container.innerHTML).not.toContain('Drawer mock')
161
+ })
146
162
 
147
- it('does not render the drawer component', () => {
148
- expect(result.find(Drawer)).not.toExist()
149
- })
163
+ it('does not render the navigation skip link', () => {
164
+ const { container } = render(<Subject headerComponent={<header>My custom header</header>} />)
150
165
 
151
- it('does not render the navigation skip link', () => {
152
- expect(result.find('a[href="#site-navigation"]')).not.toExist()
153
- })
166
+ expect(container.querySelector('a[href="#site-navigation"]')).toBeNull()
154
167
  })
155
168
  })
169
+ })
156
170
 
157
- describe('footer variations', () => {
158
- describe('with the simple variant', () => {
159
- let result
171
+ describe('footer variations', () => {
172
+ describe('with the simple variant', () => {
173
+ it('renders the footer component', () => {
174
+ const { container } = render(<Subject footerVariant={'simple' as any} />)
160
175
 
161
- beforeAll(() => {
162
- result = shallow(<Subject footerVariant={'simple' as any} />)
163
- })
176
+ expect(container.innerHTML).toContain('Footer mock')
177
+ })
164
178
 
165
- it('renders the footer component', () => {
166
- expect(result.find(Footer)).toExist()
167
- })
179
+ it('renders the footer skip link', () => {
180
+ const { container } = render(<Subject footerVariant={'simple' as any} />)
168
181
 
169
- it('renders the footer skip link', () => {
170
- expect(result.find('a[href="#site-footer"]')).toExist()
171
- })
182
+ expect(container.querySelector('a[href="#site-footer"]')).not.toBeNull()
172
183
  })
184
+ })
173
185
 
174
- describe('with the legal variant', () => {
175
- let result
186
+ describe('with the legal variant', () => {
187
+ it('renders the legal footer component', () => {
188
+ const { container } = render(<Subject footerVariant={'legal' as any} />)
176
189
 
177
- beforeAll(() => {
178
- result = shallow(<Subject footerVariant={'legal' as any} />)
179
- })
190
+ expect(container.innerHTML).toContain('LegalFooter mock')
191
+ })
180
192
 
181
- it('renders the legal footer component', () => {
182
- expect(result.find(LegalFooter)).toExist()
183
- })
193
+ it('renders the footer skip link', () => {
194
+ const { container } = render(<Subject footerVariant={'legal' as any} />)
184
195
 
185
- it('renders the footer skip link', () => {
186
- expect(result.find('a[href="#site-footer"]')).toExist()
187
- })
196
+ expect(container.querySelector('a[href="#site-footer"]')).not.toBeNull()
188
197
  })
198
+ })
189
199
 
190
- describe('with the footer disabled', () => {
191
- let result
200
+ describe('with the footer disabled', () => {
201
+ it('does not render the footer component', () => {
202
+ const { container } = render(<Subject footerVariant={false} />)
192
203
 
193
- beforeAll(() => {
194
- result = shallow(<Subject footerVariant={false} />)
195
- })
204
+ expect(container.innerHTML).not.toContain('Footer mock')
205
+ })
196
206
 
197
- it('does not render the footer component', () => {
198
- expect(result.find(Footer)).not.toExist()
199
- })
207
+ it('does not render the footer skip link', () => {
208
+ const { container } = render(<Subject footerVariant={false} />)
200
209
 
201
- it('does not render the footer skip link', () => {
202
- expect(result.find('a[href="#site-footer"]')).not.toExist()
203
- })
210
+ expect(container.querySelector('a[href="#site-footer"]')).toBeNull()
204
211
  })
212
+ })
213
+ })
205
214
 
206
- describe('with a custom footer component', () => {
207
- let result
215
+ describe('with a custom footer component', () => {
216
+ it('renders the given component', () => {
217
+ const { container } = render(<Subject footerComponent={<footer>My custom footer</footer>} />)
208
218
 
209
- beforeAll(() => {
210
- const customFooter = <footer>My custom footer</footer>
211
- result = shallow(<Subject footerComponent={customFooter} />)
212
- })
219
+ expect(container.innerHTML).toContain('My custom footer')
220
+ })
213
221
 
214
- it('renders the given component', () => {
215
- expect(result.find('footer')).toHaveText('My custom footer')
216
- })
222
+ it('does not render the footer component', () => {
223
+ const { container } = render(<Subject footerComponent={<footer>My custom footer</footer>} />)
217
224
 
218
- it('does not render the footer component', () => {
219
- expect(result.find(Footer)).not.toExist()
220
- })
225
+ expect(container.innerHTML).not.toContain('Footer mock')
226
+ })
221
227
 
222
- it('does not render the footer skip link', () => {
223
- expect(result.find('a[href="#site-footer"]')).not.toExist()
224
- })
225
- })
228
+ it('does not render the footer skip link', () => {
229
+ const { container } = render(<Subject footerComponent={<footer>My custom footer</footer>} />)
230
+
231
+ expect(container.querySelector('a[href="#site-footer"]')).toBeNull()
226
232
  })
227
233
  })
@@ -1,24 +1,24 @@
1
1
  /**
2
2
  * @jest-environment jsdom
3
3
  */
4
- import 'jest-enzyme'
5
4
  import React from 'react'
6
- import { mount } from 'enzyme'
5
+ import { render } from '@testing-library/react'
7
6
 
8
7
  import Subject from '../Template'
9
8
 
10
9
  describe('dotcom-ui-layout/src/components/Template', () => {
11
10
  it('can render contents provided as a string', () => {
12
- const result = mount(<Subject>{'<p>Hello World</p>'}</Subject>)
13
- expect(result.html()).toBe('<div><p>Hello World</p></div>')
11
+ const { container } = render(<Subject>{'<p>Hello World</p>'}</Subject>)
12
+
13
+ expect(container.outerHTML).toContain('<div><p>Hello World</p></div>')
14
14
  })
15
15
 
16
16
  it('can render contents provided as children', () => {
17
- const result = mount(
17
+ const { container } = render(
18
18
  <Subject>
19
19
  <p>Hello World</p>
20
20
  </Subject>
21
21
  )
22
- expect(result.html()).toBe('<div><p>Hello World</p></div>')
22
+ expect(container.outerHTML).toContain('<div><p>Hello World</p></div>')
23
23
  })
24
- })
24
+ })