@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/dist/browser/components/Layout.d.ts +1 -1
- package/dist/browser/components/Template.d.ts +1 -1
- package/dist/node/components/Layout.d.ts +1 -1
- package/dist/node/components/Template.d.ts +1 -1
- package/dist/node/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1384 -554
- package/package.json +8 -8
- package/src/components/__test__/Layout.spec.tsx +160 -154
- package/src/components/__test__/Template.spec.tsx +7 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/dotcom-ui-layout",
|
|
3
|
-
"version": "9.0.
|
|
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.
|
|
26
|
-
"@financial-times/dotcom-ui-base-styles": "^9.0.
|
|
27
|
-
"@financial-times/dotcom-ui-footer": "^9.0.
|
|
28
|
-
"@financial-times/dotcom-ui-header": "^9.0.
|
|
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": "
|
|
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 {
|
|
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
|
-
|
|
13
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
22
|
-
expect(
|
|
23
|
-
expect(
|
|
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
|
|
27
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
let result
|
|
54
|
+
expect(container.innerHTML).toContain('Drawer mock')
|
|
55
|
+
})
|
|
33
56
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
57
|
+
it('renders the navigation skip link', () => {
|
|
58
|
+
const { container } = render(<Subject headerVariant={'simple' as any} />)
|
|
37
59
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
60
|
+
expect(container.querySelector('a[href="#site-navigation"]')).not.toBeNull()
|
|
61
|
+
})
|
|
62
|
+
})
|
|
41
63
|
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
47
|
-
expect(result.find('a[href="#site-navigation"]')).toExist()
|
|
48
|
-
})
|
|
68
|
+
expect(container.innerHTML).toContain('Header mock')
|
|
49
69
|
})
|
|
50
70
|
|
|
51
|
-
|
|
52
|
-
|
|
71
|
+
it('renders the drawer component', () => {
|
|
72
|
+
const { container } = render(<Subject headerVariant={'large-logo' as any} />)
|
|
53
73
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
74
|
+
expect(container.innerHTML).toContain('Drawer mock')
|
|
75
|
+
})
|
|
57
76
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})
|
|
77
|
+
it('renders the navigation skip link', () => {
|
|
78
|
+
const { container } = render(<Subject headerVariant={'large-logo' as any} />)
|
|
61
79
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
expect(container.querySelector('a[href="#site-navigation"]')).not.toBeNull()
|
|
81
|
+
})
|
|
82
|
+
})
|
|
65
83
|
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
72
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
})
|
|
97
|
+
it('does not render the navigation skip link', () => {
|
|
98
|
+
const { container } = render(<Subject headerVariant={'logo-only' as any} />)
|
|
77
99
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
100
|
+
expect(container.querySelector('a[href="#site-navigation"]')).toBeNull()
|
|
101
|
+
})
|
|
102
|
+
})
|
|
81
103
|
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
87
|
-
expect(result.find('a[href="#site-navigation"]')).not.toExist()
|
|
88
|
-
})
|
|
108
|
+
expect(container.innerHTML).toContain('NoOutboundLinksHeader mock')
|
|
89
109
|
})
|
|
90
110
|
|
|
91
|
-
|
|
92
|
-
|
|
111
|
+
it('does not render the drawer component', () => {
|
|
112
|
+
const { container } = render(<Subject headerVariant={'no-outbound-links' as any} />)
|
|
93
113
|
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
120
|
+
expect(container.querySelector('a[href="#site-navigation"]')).toBeNull()
|
|
121
|
+
})
|
|
122
|
+
})
|
|
101
123
|
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
107
|
-
expect(result.find('a[href="#site-navigation"]')).not.toExist()
|
|
108
|
-
})
|
|
128
|
+
expect(container.innerHTML).not.toContain('Header mock')
|
|
109
129
|
})
|
|
110
130
|
|
|
111
|
-
|
|
112
|
-
|
|
131
|
+
it('does not render the drawer component', () => {
|
|
132
|
+
const { container } = render(<Subject headerVariant={false} />)
|
|
113
133
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
})
|
|
134
|
+
expect(container.innerHTML).not.toContain('Drawer mock')
|
|
135
|
+
})
|
|
117
136
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
})
|
|
137
|
+
it('does not render the navigation skip link', () => {
|
|
138
|
+
const { container } = render(<Subject headerVariant={false} />)
|
|
121
139
|
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
127
|
-
expect(result.find('a[href="#site-navigation"]')).not.toExist()
|
|
128
|
-
})
|
|
148
|
+
expect(container.innerHTML).toContain('My custom header')
|
|
129
149
|
})
|
|
130
150
|
|
|
131
|
-
|
|
132
|
-
|
|
151
|
+
it('does not render the header component', () => {
|
|
152
|
+
const { container } = render(<Subject headerComponent={<header>My custom header</header>} />)
|
|
133
153
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
result = shallow(<Subject headerComponent={customHeader} />)
|
|
137
|
-
})
|
|
154
|
+
expect(container.innerHTML).not.toContain('Header mock')
|
|
155
|
+
})
|
|
138
156
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
})
|
|
157
|
+
it('does not render the drawer component', () => {
|
|
158
|
+
const { container } = render(<Subject headerComponent={<header>My custom header</header>} />)
|
|
142
159
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
})
|
|
160
|
+
expect(container.innerHTML).not.toContain('Drawer mock')
|
|
161
|
+
})
|
|
146
162
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
})
|
|
163
|
+
it('does not render the navigation skip link', () => {
|
|
164
|
+
const { container } = render(<Subject headerComponent={<header>My custom header</header>} />)
|
|
150
165
|
|
|
151
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
})
|
|
176
|
+
expect(container.innerHTML).toContain('Footer mock')
|
|
177
|
+
})
|
|
164
178
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
})
|
|
179
|
+
it('renders the footer skip link', () => {
|
|
180
|
+
const { container } = render(<Subject footerVariant={'simple' as any} />)
|
|
168
181
|
|
|
169
|
-
|
|
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
|
-
|
|
175
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
})
|
|
190
|
+
expect(container.innerHTML).toContain('LegalFooter mock')
|
|
191
|
+
})
|
|
180
192
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
})
|
|
193
|
+
it('renders the footer skip link', () => {
|
|
194
|
+
const { container } = render(<Subject footerVariant={'legal' as any} />)
|
|
184
195
|
|
|
185
|
-
|
|
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
|
-
|
|
191
|
-
|
|
200
|
+
describe('with the footer disabled', () => {
|
|
201
|
+
it('does not render the footer component', () => {
|
|
202
|
+
const { container } = render(<Subject footerVariant={false} />)
|
|
192
203
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
})
|
|
204
|
+
expect(container.innerHTML).not.toContain('Footer mock')
|
|
205
|
+
})
|
|
196
206
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
})
|
|
207
|
+
it('does not render the footer skip link', () => {
|
|
208
|
+
const { container } = render(<Subject footerVariant={false} />)
|
|
200
209
|
|
|
201
|
-
|
|
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
|
-
|
|
207
|
-
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
result = shallow(<Subject footerComponent={customFooter} />)
|
|
212
|
-
})
|
|
219
|
+
expect(container.innerHTML).toContain('My custom footer')
|
|
220
|
+
})
|
|
213
221
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
})
|
|
222
|
+
it('does not render the footer component', () => {
|
|
223
|
+
const { container } = render(<Subject footerComponent={<footer>My custom footer</footer>} />)
|
|
217
224
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
})
|
|
225
|
+
expect(container.innerHTML).not.toContain('Footer mock')
|
|
226
|
+
})
|
|
221
227
|
|
|
222
|
-
|
|
223
|
-
|
|
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 {
|
|
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
|
|
13
|
-
|
|
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
|
|
17
|
+
const { container } = render(
|
|
18
18
|
<Subject>
|
|
19
19
|
<p>Hello World</p>
|
|
20
20
|
</Subject>
|
|
21
21
|
)
|
|
22
|
-
expect(
|
|
22
|
+
expect(container.outerHTML).toContain('<div><p>Hello World</p></div>')
|
|
23
23
|
})
|
|
24
|
-
})
|
|
24
|
+
})
|