@financial-times/dotcom-ui-header 7.3.0 → 7.3.2

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/dist/node/components/drawer/additionalPartials.d.ts +11 -0
  2. package/dist/node/components/drawer/topLevelPartials.d.ts +3 -0
  3. package/dist/node/components/navigation/partials.d.ts +8 -0
  4. package/dist/node/components/search/partials.d.ts +5 -0
  5. package/dist/node/components/sticky/partials.d.ts +10 -0
  6. package/dist/node/components/sub-navigation/partials.d.ts +4 -0
  7. package/dist/node/components/svg-components/BrandFtMasthead.d.ts +6 -0
  8. package/dist/node/components/top/partials.d.ts +24 -0
  9. package/dist/node/index.d.ts +38 -0
  10. package/dist/node/utils.d.ts +2 -0
  11. package/dist/tsconfig.tsbuildinfo +2124 -0
  12. package/package.json +12 -6
  13. package/src/__stories__/demos.scss +28 -0
  14. package/src/__stories__/story-data/actionsUK.ts +5 -0
  15. package/src/__stories__/story-data/anon.ts +24 -0
  16. package/src/__stories__/story-data/drawerUK.ts +968 -0
  17. package/src/__stories__/story-data/editionsInternational.ts +8 -0
  18. package/src/__stories__/story-data/editionsUK.ts +8 -0
  19. package/src/__stories__/story-data/index.ts +41 -0
  20. package/src/__stories__/story-data/navbarRight.ts +19 -0
  21. package/src/__stories__/story-data/navbarRightAnon.ts +19 -0
  22. package/src/__stories__/story-data/navbarSimple.ts +24 -0
  23. package/src/__stories__/story-data/navbarUK.ts +996 -0
  24. package/src/__stories__/story-data/profile.ts +44 -0
  25. package/src/__stories__/story-data/subNavigationProfile.ts +27 -0
  26. package/src/__stories__/story-data/subNavigationUK.ts +37 -0
  27. package/src/__stories__/story-data/user.ts +13 -0
  28. package/src/__stories__/story.tsx +163 -0
  29. package/src/__test__/components/Drawer.spec.tsx +19 -0
  30. package/src/__test__/components/MainHeader.spec.tsx +26 -0
  31. package/src/__test__/components/NoOutboundLinks.spec.tsx +19 -0
  32. package/src/__test__/components/StickyHeader.spec.tsx +19 -0
  33. package/src/__test__/components/__snapshots__/Drawer.spec.tsx.snap +2718 -0
  34. package/src/__test__/components/__snapshots__/MainHeader.spec.tsx.snap +5547 -0
  35. package/src/__test__/components/__snapshots__/NoOutboundLinks.spec.tsx.snap +337 -0
  36. package/src/__test__/components/__snapshots__/StickyHeader.spec.tsx.snap +588 -0
  37. package/src/__test__/enzyme/component.spec.tsx +107 -0
  38. package/src/__test__/enzyme/drawer.spec.tsx +114 -0
  39. package/screenshots/header-navigation.png +0 -0
  40. package/screenshots/header-sub-navigation.png +0 -0
  41. package/screenshots/header-top-search.png +0 -0
  42. package/scripts/convertSvgsToReactComponents.js +0 -23
@@ -0,0 +1,114 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ import 'jest-enzyme'
5
+ import React from 'react'
6
+ import { mount } from 'enzyme'
7
+
8
+ import navigationData from '../../__stories__/story-data/index'
9
+ import { Drawer as Subject } from '../../'
10
+
11
+ const fixture = {
12
+ data: { ...navigationData.data, currentPath: '/world' }
13
+ }
14
+
15
+ const loggedInUserFixture = {
16
+ ...fixture,
17
+ userIsAnonymous: false,
18
+ userIsLoggedIn: true
19
+ }
20
+
21
+ const anonymousUserFixture = {
22
+ ...fixture,
23
+ userIsAnonymous: true,
24
+ userIsLoggedIn: false
25
+ }
26
+
27
+ describe('dotcom-ui-header/src/components/drawer', () => {
28
+ describe('editions', () => {
29
+ let result
30
+
31
+ beforeAll(() => {
32
+ result = mount(<Subject {...fixture} />)
33
+ })
34
+
35
+ it('renders the current edition text', () => {
36
+ expect(result.find('.o-header__drawer-current-edition')).toHaveText('UK Edition')
37
+ })
38
+
39
+ it('renders the alternative edition link', () => {
40
+ expect(result.find('[data-trackable="edition-switcher"] a')).toHaveText(
41
+ 'Switch to International Edition'
42
+ )
43
+ })
44
+ })
45
+
46
+ describe('navigation links', () => {
47
+ let result
48
+
49
+ beforeAll(() => {
50
+ result = mount(<Subject {...fixture} />)
51
+ })
52
+
53
+ it('renders the primary link section title', () => {
54
+ expect(result.find('.o-header__drawer-menu-item--heading').at(0)).toHaveText('Top sections')
55
+ })
56
+
57
+ it('renders the secondary link section title', () => {
58
+ expect(result.find('.o-header__drawer-menu-item--heading').at(1)).toHaveText('FT recommends')
59
+ })
60
+
61
+ it('renders the tertiary link section divider', () => {
62
+ expect(result.find('.o-header__drawer-menu-list--divide > li:first-child')).toHaveText('myFT')
63
+ })
64
+
65
+ it('renders primary link subsections', () => {
66
+ const section = result
67
+ .find('.o-header__drawer-menu-item')
68
+ .findWhere((node) => node.key() === '/companies')
69
+ .at(0)
70
+
71
+ expect(section.find('.o-header__drawer-menu-link--parent')).toHaveText('Companies')
72
+ expect(section.find('.o-header__drawer-menu-toggle')).toHaveText('Show more Companies')
73
+ expect(section.find('.o-header__drawer-menu-link--child').length).toBe(10)
74
+ })
75
+
76
+ it('highlights the current page', () => {
77
+ expect(result.find('[aria-current="page"]')).toHaveText('World')
78
+ })
79
+ })
80
+
81
+ describe('user menu', () => {
82
+ describe('for a logged in user', () => {
83
+ let result
84
+
85
+ beforeAll(() => {
86
+ result = mount(<Subject {...loggedInUserFixture} />)
87
+ })
88
+
89
+ it('renders sign out link', () => {
90
+ expect(result.find('a[data-trackable="Sign Out"]')).toExist()
91
+ })
92
+
93
+ it('renders settings and account link', () => {
94
+ expect(result.find('a[data-trackable="Settings & Account"]')).toExist()
95
+ })
96
+ })
97
+
98
+ describe('for an anonymous user', () => {
99
+ let result
100
+
101
+ beforeAll(() => {
102
+ result = mount(<Subject {...anonymousUserFixture} />)
103
+ })
104
+
105
+ it('renders sign in link', () => {
106
+ expect(result.find('a[data-trackable="Sign In"]')).toExist()
107
+ })
108
+
109
+ it('renders subscribe link', () => {
110
+ expect(result.find('a[data-trackable="Subscribe"]')).toExist()
111
+ })
112
+ })
113
+ })
114
+ })
Binary file
Binary file
@@ -1,23 +0,0 @@
1
- const fs = require('fs')
2
-
3
- const camelCase = require('camelcase')
4
- const svgr = require('@svgr/core').default
5
-
6
- const logoNames = ['brand-ft-masthead']
7
-
8
- logoNames.forEach((logoName) => {
9
- const pathToSvg = require.resolve(`@financial-times/logo-images/src/${logoName}.svg`)
10
-
11
- const svgString = fs.readFileSync(pathToSvg).toString()
12
-
13
- const componentName = camelCase(logoName, { pascalCase: true })
14
-
15
- svgr(svgString, { titleProp: true }, { componentName }).then((jsCode) => {
16
- const comment =
17
- '// **THIS IS AN AUTO-GENERATED FILE (`npm run build:svg-to-react`) - DO NOT EDIT MANUALLY.**\n\n'
18
-
19
- const fileExtension = 'tsx'
20
-
21
- fs.writeFileSync(`src/components/svg-components/${componentName}.${fileExtension}`, comment + jsCode)
22
- })
23
- })