@times-components/ts-components 1.31.0 → 1.32.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/CHANGELOG.md +30 -0
- package/dist/components/article-header/ArticleHeader.d.ts +2 -1
- package/dist/components/article-header/ArticleHeader.js +21 -18
- package/dist/components/article-header/ArticleHeader.stories.js +18 -23
- package/dist/components/article-header/__tests__/ArticleHeader.test.js +59 -91
- package/dist/components/article-header/styles.d.ts +1 -3
- package/dist/components/article-header/styles.js +2 -2
- package/package.json +15 -14
- package/rnw.js +1 -1
- package/src/components/article-header/ArticleHeader.stories.tsx +28 -28
- package/src/components/article-header/ArticleHeader.tsx +35 -25
- package/src/components/article-header/__tests__/ArticleHeader.test.tsx +104 -136
- package/src/components/article-header/__tests__/__snapshots__/ArticleHeader.test.tsx.snap +23 -68
- package/src/components/article-header/styles.ts +2 -2
- package/src/components/latest-from-section/__tests__/__snapshots__/LatestFromSection.test.tsx.snap +6 -9
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { storiesOf } from '@storybook/react';
|
|
3
|
-
import {
|
|
3
|
+
import { select, text } from '@storybook/addon-knobs';
|
|
4
|
+
import { format, addMinutes } from 'date-fns';
|
|
5
|
+
import { utcToZonedTime } from 'date-fns-tz';
|
|
4
6
|
|
|
5
7
|
import { ArticleHarness } from '../../fixtures/article-harness/ArticleHarness';
|
|
6
8
|
import ArticleHeader from './ArticleHeader';
|
|
7
9
|
|
|
10
|
+
const getAttributes = () => {
|
|
11
|
+
const id = 'Options';
|
|
12
|
+
|
|
13
|
+
const now = utcToZonedTime(new Date(), 'Europe/London');
|
|
14
|
+
|
|
15
|
+
const date = text('Date', format(now, 'dd/MM/yyyy'), id);
|
|
16
|
+
const time = text('Time', format(addMinutes(now, -10), 'HH:mm'), id);
|
|
17
|
+
|
|
18
|
+
const options = { True: 'true', False: undefined };
|
|
19
|
+
const breaking = select('Breaking', options, 'true', id);
|
|
20
|
+
|
|
21
|
+
const headline = text('Headline', 'This is the headline', id);
|
|
22
|
+
|
|
23
|
+
return { date, time, breaking, headline };
|
|
24
|
+
};
|
|
25
|
+
|
|
8
26
|
storiesOf('Typescript Component/Article Header', module)
|
|
9
27
|
.addDecorator((storyFn: () => React.ReactNode) => (
|
|
10
28
|
<ArticleHarness>{storyFn()}</ArticleHarness>
|
|
11
29
|
))
|
|
12
30
|
.add('Article Header with headline', () => {
|
|
13
|
-
const
|
|
14
|
-
const defaultValue = new Date();
|
|
15
|
-
const groupId = 'Options';
|
|
16
|
-
const value = date(label, defaultValue, groupId);
|
|
17
|
-
const breakingOptions = {
|
|
18
|
-
True: 'true',
|
|
19
|
-
False: undefined
|
|
20
|
-
};
|
|
21
|
-
const updated = new Date(value).toISOString();
|
|
22
|
-
|
|
23
|
-
const headline = text('Headline', 'This is the headline', groupId);
|
|
24
|
-
|
|
31
|
+
const props = getAttributes();
|
|
25
32
|
return (
|
|
26
33
|
<ArticleHeader
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
date={props.date}
|
|
35
|
+
time={props.time}
|
|
36
|
+
breaking={props.breaking}
|
|
37
|
+
headline={encodeURIComponent(props.headline)}
|
|
30
38
|
/>
|
|
31
39
|
);
|
|
32
40
|
})
|
|
33
41
|
.add('Article Header without headline', () => {
|
|
34
|
-
const
|
|
35
|
-
const defaultValue = new Date();
|
|
36
|
-
const groupId = 'Options';
|
|
37
|
-
const value = date(label, defaultValue, groupId);
|
|
38
|
-
const breakingOptions = {
|
|
39
|
-
True: 'true',
|
|
40
|
-
False: undefined
|
|
41
|
-
};
|
|
42
|
-
const updated = new Date(value).toISOString();
|
|
43
|
-
|
|
42
|
+
const props = getAttributes();
|
|
44
43
|
return (
|
|
45
44
|
<ArticleHeader
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
date={props.date}
|
|
46
|
+
time={props.time}
|
|
47
|
+
breaking={props.breaking}
|
|
48
48
|
/>
|
|
49
49
|
);
|
|
50
50
|
});
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {
|
|
3
|
+
parse,
|
|
3
4
|
format,
|
|
4
5
|
differenceInSeconds,
|
|
5
6
|
differenceInCalendarDays,
|
|
6
7
|
formatDistanceStrict
|
|
7
8
|
} from 'date-fns';
|
|
9
|
+
import { zonedTimeToUtc } from 'date-fns-tz';
|
|
10
|
+
|
|
11
|
+
import { BreakingArticleFlag } from '../article-flag/LiveArticleFlag';
|
|
12
|
+
import safeDecodeURIComponent from '../../utils/safeDecodeURIComponent';
|
|
8
13
|
|
|
9
14
|
import {
|
|
10
15
|
Container,
|
|
@@ -18,39 +23,46 @@ import {
|
|
|
18
23
|
UpdatesContainer,
|
|
19
24
|
FlagContainer
|
|
20
25
|
} from './styles';
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
|
|
27
|
+
const anchorString = (updateTxt = '', headlineTxt = '') => {
|
|
28
|
+
const onlyNumbersReg = /\D+/g;
|
|
29
|
+
const onlyNumbers = updateTxt.replace(onlyNumbersReg, '');
|
|
30
|
+
const acronymReg = /\b(\w)/g;
|
|
31
|
+
const acronymMatch = headlineTxt.match(acronymReg);
|
|
32
|
+
const acronym = acronymMatch === null ? '' : acronymMatch.join('');
|
|
33
|
+
return `u_${onlyNumbers}${acronym}`;
|
|
34
|
+
};
|
|
23
35
|
|
|
24
36
|
const ArticleHeader: React.FC<{
|
|
25
|
-
|
|
37
|
+
date: string;
|
|
38
|
+
time: string;
|
|
26
39
|
breaking?: string;
|
|
27
40
|
headline?: string;
|
|
28
|
-
}> = ({
|
|
41
|
+
}> = ({ date, time, breaking, headline }) => {
|
|
29
42
|
const currentDateTime = new Date();
|
|
30
|
-
|
|
43
|
+
|
|
44
|
+
const updated = `${date} ${time}`;
|
|
45
|
+
const parsedDate = parse(updated, 'dd/MM/yyyy HH:mm', new Date());
|
|
46
|
+
const updatedDate = zonedTimeToUtc(parsedDate, 'Europe/London');
|
|
47
|
+
|
|
31
48
|
const timeSincePublishing =
|
|
32
49
|
formatDistanceStrict(updatedDate, currentDateTime, {
|
|
33
50
|
roundingMethod: 'floor'
|
|
34
51
|
}) + ' ago';
|
|
35
|
-
const diffInSeconds = differenceInSeconds(currentDateTime, updatedDate);
|
|
36
|
-
const anchorString = (updateTxt = '', headlineTxt = '') => {
|
|
37
|
-
const onlyNumbersReg = /\D+/g;
|
|
38
|
-
const onlyNumbers = updateTxt.replace(onlyNumbersReg, '');
|
|
39
|
-
const acronymReg = /\b(\w)/g;
|
|
40
|
-
const acronymMatch = headlineTxt.match(acronymReg);
|
|
41
|
-
const acronym = acronymMatch === null ? '' : acronymMatch.join('');
|
|
42
|
-
return `u_${onlyNumbers}${acronym}`;
|
|
43
|
-
};
|
|
44
52
|
|
|
53
|
+
const diffInSeconds = differenceInSeconds(currentDateTime, updatedDate);
|
|
45
54
|
const isLessThan1Minute = diffInSeconds < 60;
|
|
46
55
|
const isLessThan1Hour = diffInSeconds < 60 * 60;
|
|
47
56
|
const isLessThan13Hours = diffInSeconds < 60 * 60 * 13;
|
|
48
|
-
|
|
49
|
-
const
|
|
57
|
+
|
|
58
|
+
const isDaysAgo = differenceInCalendarDays(currentDateTime, parsedDate) >= 1;
|
|
59
|
+
|
|
50
60
|
const isBreaking = breaking
|
|
51
61
|
? Boolean(breaking.toLowerCase() === 'true')
|
|
52
62
|
: false;
|
|
53
63
|
|
|
64
|
+
const anchorPoint = anchorString(updated, headline);
|
|
65
|
+
|
|
54
66
|
return (
|
|
55
67
|
<Container isBreaking={isBreaking && isLessThan1Hour} id={anchorPoint}>
|
|
56
68
|
<UpdatesContainer>
|
|
@@ -60,30 +72,28 @@ const ArticleHeader: React.FC<{
|
|
|
60
72
|
<BreakingArticleFlag />
|
|
61
73
|
</FlagContainer>
|
|
62
74
|
) : null}
|
|
75
|
+
|
|
63
76
|
{!isLessThan1Minute && isLessThan13Hours ? (
|
|
64
77
|
<TimeSincePublishingContainer>
|
|
65
|
-
<TimeSincePublishing
|
|
66
|
-
isBreaking={isBreaking}
|
|
67
|
-
data-testId="TimeSincePublishing"
|
|
68
|
-
>
|
|
78
|
+
<TimeSincePublishing data-testId="TimeSincePublishing">
|
|
69
79
|
{timeSincePublishing}
|
|
70
80
|
</TimeSincePublishing>
|
|
71
81
|
<Divider />
|
|
72
82
|
</TimeSincePublishingContainer>
|
|
73
83
|
) : null}
|
|
84
|
+
|
|
74
85
|
<UpdatedTime
|
|
75
86
|
isLessThan13Hours={!isLessThan1Minute && isLessThan13Hours}
|
|
76
|
-
data-testId="UpdatedTime"
|
|
77
87
|
>
|
|
78
|
-
{format(
|
|
88
|
+
{format(parsedDate, 'h.mmaaa')}
|
|
79
89
|
</UpdatedTime>
|
|
80
90
|
</UpdatedTimeItems>
|
|
91
|
+
|
|
81
92
|
{isDaysAgo ? (
|
|
82
|
-
<UpdatedDate
|
|
83
|
-
{format(updatedDate, 'MMMM d yyyy')}
|
|
84
|
-
</UpdatedDate>
|
|
93
|
+
<UpdatedDate>{format(parsedDate, 'MMMM d yyyy')}</UpdatedDate>
|
|
85
94
|
) : null}
|
|
86
95
|
</UpdatesContainer>
|
|
96
|
+
|
|
87
97
|
{headline && <Headline>{safeDecodeURIComponent(headline)}</Headline>}
|
|
88
98
|
</Container>
|
|
89
99
|
);
|
|
@@ -1,183 +1,151 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom';
|
|
4
|
+
import MockDate from 'mockdate';
|
|
4
5
|
|
|
5
6
|
import ArticleHeader from '../ArticleHeader';
|
|
6
|
-
import MockDate from 'mockdate';
|
|
7
7
|
|
|
8
8
|
describe('ArticleHeader', () => {
|
|
9
|
-
describe('
|
|
10
|
-
const updated = '2021-12-31T06:30:00Z';
|
|
9
|
+
describe('Same calendar day during GMT', () => {
|
|
11
10
|
afterEach(() => MockDate.reset());
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
|
|
12
|
+
const date = '31/12/2021';
|
|
13
|
+
const time = '06:30';
|
|
14
|
+
|
|
15
|
+
it('Within a minute of updating', () => {
|
|
16
|
+
MockDate.set('2021-12-31T06:30:10Z');
|
|
17
|
+
|
|
18
|
+
const { getByText, queryByTestId } = render(
|
|
19
|
+
<ArticleHeader date={date} time={time} />
|
|
20
20
|
);
|
|
21
|
-
|
|
22
|
-
expect(getByText('BREAKING')).toBeVisible();
|
|
23
|
-
expect(queryByTestId('UpdatedTime')).toBeTruthy();
|
|
21
|
+
|
|
24
22
|
expect(getByText('6.30am')).toBeVisible();
|
|
25
23
|
expect(queryByTestId('TimeSincePublishing')).toBeFalsy();
|
|
26
|
-
expect(queryByTestId('UpdatedDate')).toBeFalsy();
|
|
27
|
-
expect(getByText('This is the headline')).toBeVisible();
|
|
28
24
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
headline="This%20is%20the%20headline"
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
38
|
-
expect(baseElement).toMatchSnapshot();
|
|
39
|
-
expect(queryByText('BREAKING')).toBeFalsy();
|
|
40
|
-
expect(queryByTestId('UpdatedTime')).toBeTruthy();
|
|
25
|
+
|
|
26
|
+
it('Within an hour of updating', () => {
|
|
27
|
+
MockDate.set('2021-12-31T07:00:00Z');
|
|
28
|
+
|
|
29
|
+
const { getByText } = render(<ArticleHeader date={date} time={time} />);
|
|
30
|
+
|
|
41
31
|
expect(getByText('6.30am')).toBeVisible();
|
|
42
|
-
expect(
|
|
43
|
-
expect(queryByTestId('UpdatedDate')).toBeFalsy();
|
|
44
|
-
expect(getByText('This is the headline')).toBeVisible();
|
|
32
|
+
expect(getByText('30 minutes ago')).toBeVisible();
|
|
45
33
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
|
|
35
|
+
it('Between 1 and 12 hours after updating', () => {
|
|
36
|
+
MockDate.set('2021-12-31T08:30:00Z');
|
|
37
|
+
|
|
38
|
+
const { getByText } = render(<ArticleHeader date={date} time={time} />);
|
|
39
|
+
|
|
40
|
+
expect(getByText('6.30am')).toBeVisible();
|
|
41
|
+
expect(getByText('2 hours ago')).toBeVisible();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('After 12 hours but same calendar day', () => {
|
|
45
|
+
MockDate.set('2021-12-20T20:30:00Z');
|
|
46
|
+
|
|
47
|
+
const { getByText, queryByTestId } = render(
|
|
48
|
+
<ArticleHeader date={date} time={time} />
|
|
50
49
|
);
|
|
51
|
-
|
|
52
|
-
expect(queryByText('This is the headline')).toBeFalsy();
|
|
53
|
-
expect(queryByText('BREAKING')).toBeFalsy();
|
|
54
|
-
expect(queryByTestId('UpdatedTime')).toBeTruthy();
|
|
50
|
+
|
|
55
51
|
expect(getByText('6.30am')).toBeVisible();
|
|
56
52
|
expect(queryByTestId('TimeSincePublishing')).toBeFalsy();
|
|
57
|
-
expect(queryByTestId('UpdatedDate')).toBeFalsy();
|
|
58
53
|
});
|
|
59
|
-
|
|
54
|
+
|
|
55
|
+
it('With breaking flag and headline', () => {
|
|
60
56
|
MockDate.set('2021-12-31T07:00:00Z');
|
|
61
|
-
|
|
57
|
+
|
|
58
|
+
const { baseElement, getByText } = render(
|
|
62
59
|
<ArticleHeader
|
|
63
|
-
|
|
60
|
+
date={date}
|
|
61
|
+
time={time}
|
|
64
62
|
breaking="true"
|
|
65
63
|
headline="This%20is%20the%20headline"
|
|
66
64
|
/>
|
|
67
65
|
);
|
|
68
|
-
|
|
69
|
-
expect(queryByTestId('UpdatedTime')).toBeTruthy();
|
|
66
|
+
|
|
70
67
|
expect(getByText('6.30am')).toBeVisible();
|
|
71
|
-
expect(queryByTestId('TimeSincePublishing')).toBeTruthy();
|
|
72
68
|
expect(getByText('30 minutes ago')).toBeVisible();
|
|
73
|
-
expect(
|
|
69
|
+
expect(getByText('BREAKING')).toBeVisible();
|
|
74
70
|
expect(getByText('This is the headline')).toBeVisible();
|
|
71
|
+
|
|
72
|
+
expect(baseElement).toMatchSnapshot();
|
|
75
73
|
});
|
|
76
|
-
|
|
74
|
+
|
|
75
|
+
it('With breaking flag expired', () => {
|
|
77
76
|
MockDate.set('2021-12-31T08:30:00Z');
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
breaking="true"
|
|
82
|
-
headline="This%20is%20the%20headline"
|
|
83
|
-
/>
|
|
77
|
+
|
|
78
|
+
const { getByText, queryByText } = render(
|
|
79
|
+
<ArticleHeader date={date} time={time} breaking="true" />
|
|
84
80
|
);
|
|
85
|
-
|
|
86
|
-
expect(queryByTestId('UpdatedTime')).toBeTruthy();
|
|
81
|
+
|
|
87
82
|
expect(getByText('6.30am')).toBeVisible();
|
|
88
|
-
expect(queryByTestId('TimeSincePublishing')).toBeTruthy();
|
|
89
83
|
expect(getByText('2 hours ago')).toBeVisible();
|
|
90
|
-
expect(queryByTestId('UpdatedDate')).toBeFalsy();
|
|
91
|
-
expect(getByText('This is the headline')).toBeVisible();
|
|
92
|
-
});
|
|
93
|
-
it('after 12 hours but on the same calendar day', () => {
|
|
94
|
-
MockDate.set('2021-12-31T19:30:00Z');
|
|
95
|
-
const { getByText, queryByTestId, queryByText } = render(
|
|
96
|
-
<ArticleHeader
|
|
97
|
-
updated={updated}
|
|
98
|
-
breaking="true"
|
|
99
|
-
headline="This%20is%20the%20headline"
|
|
100
|
-
/>
|
|
101
|
-
);
|
|
102
84
|
expect(queryByText('BREAKING')).toBeFalsy();
|
|
103
|
-
expect(queryByTestId('UpdatedTime')).toBeTruthy();
|
|
104
|
-
expect(getByText('6.30am')).toBeVisible();
|
|
105
|
-
expect(queryByTestId('TimeSincePublishing')).toBeFalsy();
|
|
106
|
-
expect(queryByTestId('UpdatedDate')).toBeFalsy();
|
|
107
|
-
expect(getByText('This is the headline')).toBeVisible();
|
|
108
85
|
});
|
|
109
86
|
});
|
|
110
|
-
|
|
111
|
-
|
|
87
|
+
|
|
88
|
+
describe('Same calendar day during BST', () => {
|
|
112
89
|
afterEach(() => MockDate.reset());
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
90
|
+
|
|
91
|
+
const date = '20/04/2022';
|
|
92
|
+
const time = '06:30';
|
|
93
|
+
|
|
94
|
+
it('Within a minute of updating', () => {
|
|
95
|
+
MockDate.set('2022-04-20T06:30:10+01:00');
|
|
96
|
+
|
|
97
|
+
const { getByText, queryByTestId } = render(
|
|
98
|
+
<ArticleHeader date={date} time={time} />
|
|
121
99
|
);
|
|
122
|
-
|
|
123
|
-
expect(
|
|
124
|
-
expect(
|
|
125
|
-
expect(getByTestId('TimeSincePublishing')).toBeTruthy();
|
|
126
|
-
expect(getByTestId('UpdatedDate')).toBeVisible();
|
|
127
|
-
expect(getByText('December 31 2021')).toBeVisible();
|
|
128
|
-
expect(getByText('This is the headline')).toBeVisible();
|
|
100
|
+
|
|
101
|
+
expect(getByText('6.30am')).toBeVisible();
|
|
102
|
+
expect(queryByTestId('TimeSincePublishing')).toBeFalsy();
|
|
129
103
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
104
|
+
|
|
105
|
+
it('Within an hour of updating', () => {
|
|
106
|
+
MockDate.set('2022-04-20T07:00:00+01:00');
|
|
107
|
+
|
|
108
|
+
const { getByText } = render(<ArticleHeader date={date} time={time} />);
|
|
109
|
+
|
|
110
|
+
expect(getByText('6.30am')).toBeVisible();
|
|
111
|
+
expect(getByText('30 minutes ago')).toBeVisible();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('Between 1 and 12 hours after updating', () => {
|
|
115
|
+
MockDate.set('2022-04-20T08:30:00+01:00');
|
|
116
|
+
|
|
117
|
+
const { getByText } = render(<ArticleHeader date={date} time={time} />);
|
|
118
|
+
|
|
119
|
+
expect(getByText('6.30am')).toBeVisible();
|
|
143
120
|
expect(getByText('2 hours ago')).toBeVisible();
|
|
144
|
-
expect(getByTestId('UpdatedDate')).toBeVisible();
|
|
145
|
-
expect(getByText('December 31 2021')).toBeVisible();
|
|
146
|
-
expect(getByText('This is the headline')).toBeVisible();
|
|
147
121
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
headline="This%20is%20the%20headline"
|
|
155
|
-
/>
|
|
122
|
+
|
|
123
|
+
it('After 12 hours but same calendar day', () => {
|
|
124
|
+
MockDate.set('2022-04-20T20:30:00+01:00');
|
|
125
|
+
|
|
126
|
+
const { getByText, queryByTestId } = render(
|
|
127
|
+
<ArticleHeader date={date} time={time} />
|
|
156
128
|
);
|
|
157
|
-
|
|
158
|
-
expect(
|
|
159
|
-
expect(getByText('11.30pm')).toBeVisible();
|
|
129
|
+
|
|
130
|
+
expect(getByText('6.30am')).toBeVisible();
|
|
160
131
|
expect(queryByTestId('TimeSincePublishing')).toBeFalsy();
|
|
161
|
-
expect(getByTestId('UpdatedDate')).toBeVisible();
|
|
162
|
-
expect(getByText('December 31 2021')).toBeVisible();
|
|
163
|
-
expect(getByText('This is the headline')).toBeVisible();
|
|
164
132
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
expect(
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('Different calendar days', () => {
|
|
136
|
+
afterEach(() => MockDate.reset());
|
|
137
|
+
|
|
138
|
+
const date = '31/12/2021';
|
|
139
|
+
const time = '22:30';
|
|
140
|
+
|
|
141
|
+
it('Between 1 and 12 hours after updating', () => {
|
|
142
|
+
MockDate.set('2022-01-01T02:30:00Z');
|
|
143
|
+
|
|
144
|
+
const { getByText } = render(<ArticleHeader date={date} time={time} />);
|
|
145
|
+
|
|
146
|
+
expect(getByText('10.30pm')).toBeVisible();
|
|
147
|
+
expect(getByText('4 hours ago')).toBeVisible();
|
|
179
148
|
expect(getByText('December 31 2021')).toBeVisible();
|
|
180
|
-
expect(getByText('This is the headline')).toBeVisible();
|
|
181
149
|
});
|
|
182
150
|
});
|
|
183
151
|
});
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`ArticleHeader
|
|
3
|
+
exports[`ArticleHeader Same calendar day during GMT With breaking flag and headline 1`] = `
|
|
4
4
|
<body>
|
|
5
5
|
<div>
|
|
6
6
|
<div
|
|
7
|
-
class="sc-
|
|
8
|
-
id="
|
|
7
|
+
class="sc-VigVT esKZlx"
|
|
8
|
+
id="u_311220210630T222"
|
|
9
9
|
>
|
|
10
10
|
<div
|
|
11
|
-
class="sc-
|
|
11
|
+
class="sc-jTzLTM hsNKrf"
|
|
12
12
|
>
|
|
13
13
|
<div
|
|
14
|
-
class="sc-
|
|
14
|
+
class="sc-cSHVUG jdArUK"
|
|
15
15
|
>
|
|
16
16
|
<div
|
|
17
|
-
class="sc-
|
|
17
|
+
class="sc-kpOJdX pPyiu"
|
|
18
18
|
>
|
|
19
19
|
<div
|
|
20
|
-
class="sc-
|
|
20
|
+
class="sc-EHOje cfBXHC"
|
|
21
21
|
>
|
|
22
22
|
<div
|
|
23
|
-
class="sc-
|
|
23
|
+
class="sc-bdVaJa bkSKmo"
|
|
24
24
|
>
|
|
25
25
|
<div
|
|
26
|
-
class="sc-
|
|
26
|
+
class="sc-htpNat jcRSar"
|
|
27
27
|
>
|
|
28
28
|
<div
|
|
29
|
-
class="sc-
|
|
29
|
+
class="sc-bxivhb hTEbzV"
|
|
30
30
|
/>
|
|
31
31
|
</div>
|
|
32
32
|
<span
|
|
33
|
-
class="sc-
|
|
33
|
+
class="sc-bwzfXH hBgZUv"
|
|
34
34
|
>
|
|
35
35
|
BREAKING
|
|
36
36
|
</span>
|
|
@@ -38,72 +38,27 @@ exports[`ArticleHeader In one calendar day Within the first minute of update - B
|
|
|
38
38
|
</div>
|
|
39
39
|
</div>
|
|
40
40
|
<div
|
|
41
|
-
class="sc-
|
|
42
|
-
data-testid="UpdatedTime"
|
|
41
|
+
class="sc-fjdhpX eXIoUS"
|
|
43
42
|
>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
</body>
|
|
56
|
-
`;
|
|
57
|
-
|
|
58
|
-
exports[`ArticleHeader In one calendar day Within the first minute of update - No headline not breaking 1`] = `
|
|
59
|
-
<body>
|
|
60
|
-
<div>
|
|
61
|
-
<div
|
|
62
|
-
class="sc-bdVaJa fLcQHz"
|
|
63
|
-
id="u_20211231063000"
|
|
64
|
-
>
|
|
65
|
-
<div
|
|
66
|
-
class="sc-bwzfXH htoLMg"
|
|
67
|
-
>
|
|
68
|
-
<div
|
|
69
|
-
class="sc-ifAKCX iDsMnF"
|
|
70
|
-
>
|
|
71
|
-
<div
|
|
72
|
-
class="sc-EHOje cDoFHw"
|
|
73
|
-
data-testid="UpdatedTime"
|
|
74
|
-
>
|
|
75
|
-
6.30am
|
|
43
|
+
<div
|
|
44
|
+
class="sc-jzJRlG ektXhQ"
|
|
45
|
+
data-testid="TimeSincePublishing"
|
|
46
|
+
>
|
|
47
|
+
30 minutes ago
|
|
48
|
+
</div>
|
|
49
|
+
<div
|
|
50
|
+
class="sc-kgoBCf gsnOug"
|
|
51
|
+
/>
|
|
76
52
|
</div>
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
</body>
|
|
82
|
-
`;
|
|
83
|
-
|
|
84
|
-
exports[`ArticleHeader In one calendar day Within the first minute of update - Not Breaking 1`] = `
|
|
85
|
-
<body>
|
|
86
|
-
<div>
|
|
87
|
-
<div
|
|
88
|
-
class="sc-bdVaJa fLcQHz"
|
|
89
|
-
id="u_20211231063000T222"
|
|
90
|
-
>
|
|
91
|
-
<div
|
|
92
|
-
class="sc-bwzfXH htoLMg"
|
|
93
|
-
>
|
|
94
|
-
<div
|
|
95
|
-
class="sc-ifAKCX iDsMnF"
|
|
96
|
-
>
|
|
97
53
|
<div
|
|
98
|
-
class="sc-
|
|
99
|
-
data-testid="UpdatedTime"
|
|
54
|
+
class="sc-kAzzGY cABvZX"
|
|
100
55
|
>
|
|
101
56
|
6.30am
|
|
102
57
|
</div>
|
|
103
58
|
</div>
|
|
104
59
|
</div>
|
|
105
60
|
<h2
|
|
106
|
-
class="sc-
|
|
61
|
+
class="sc-kGXeez crUIWF"
|
|
107
62
|
>
|
|
108
63
|
This is the headline
|
|
109
64
|
</h2>
|
|
@@ -31,7 +31,7 @@ export const TimeSincePublishingContainer = styled.div`
|
|
|
31
31
|
flex-direction: row;
|
|
32
32
|
`;
|
|
33
33
|
|
|
34
|
-
export const TimeSincePublishing = styled.div
|
|
34
|
+
export const TimeSincePublishing = styled.div`
|
|
35
35
|
color: ${colours.functional.brandColour};
|
|
36
36
|
font-family: ${fonts.supporting};
|
|
37
37
|
font-size: 14px;
|
|
@@ -63,7 +63,7 @@ export const UpdatedDate = styled.div`
|
|
|
63
63
|
export const Divider = styled.div`
|
|
64
64
|
background-color: ${colours.functional.greyLabel};
|
|
65
65
|
width: 1px;
|
|
66
|
-
margin: 2px 8px 6px
|
|
66
|
+
margin: 2px 8px 6px 8px;
|
|
67
67
|
`;
|
|
68
68
|
|
|
69
69
|
export const Headline = styled.h2`
|