Skip to content

Commit 49d5c9e

Browse files
committed
fix tests
1 parent a5c0e77 commit 49d5c9e

File tree

2 files changed

+47
-46
lines changed

2 files changed

+47
-46
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from 'react'
2+
import Interval from './Interval'
3+
export function CustomDateHeader({
4+
headerContext: { intervals, unit },
5+
getRootProps,
6+
getIntervalProps,
7+
showPeriod,
8+
data: {
9+
style,
10+
intervalRenderer,
11+
className,
12+
getLabelFormat,
13+
unitProp,
14+
headerData
15+
}
16+
}) {
17+
return (
18+
<div
19+
data-testid={`dateHeader`}
20+
className={className}
21+
{...getRootProps({ style })}
22+
>
23+
{intervals.map(interval => {
24+
const intervalText = getLabelFormat(
25+
[interval.startTime, interval.endTime],
26+
unit,
27+
interval.labelWidth
28+
)
29+
return (
30+
<Interval
31+
key={`label-${interval.startTime.valueOf()}`}
32+
unit={unit}
33+
interval={interval}
34+
showPeriod={showPeriod}
35+
intervalText={intervalText}
36+
primaryHeader={unitProp === 'primaryHeader'}
37+
getIntervalProps={getIntervalProps}
38+
intervalRenderer={intervalRenderer}
39+
headerData={headerData}
40+
/>
41+
)
42+
})}
43+
</div>
44+
)
45+
}

src/lib/headers/DateHeader.js

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { TimelineStateConsumer } from '../timeline/TimelineStateContext'
44
import CustomHeader from './CustomHeader'
55
import { getNextUnit } from '../utility/calendar'
66
import { defaultHeaderFormats } from '../default-config'
7-
import Interval from './Interval'
87
import memoize from 'memoize-one'
8+
import { CustomDateHeader } from './CustomDateHeader'
99

1010
class DateHeader extends React.Component {
1111
static propTypes = {
@@ -86,7 +86,7 @@ class DateHeader extends React.Component {
8686
this.props.unit,
8787
this.props.headerData
8888
)}
89-
children={Header}
89+
children={CustomDateHeader}
9090
/>
9191
)
9292
}
@@ -143,50 +143,6 @@ class DateHeaderWrapper extends React.Component {
143143
}
144144
}
145145

146-
function Header({
147-
headerContext: { intervals, unit },
148-
getRootProps,
149-
getIntervalProps,
150-
showPeriod,
151-
data: {
152-
style,
153-
intervalRenderer,
154-
className,
155-
getLabelFormat,
156-
unitProp,
157-
...restData
158-
}
159-
}) {
160-
return (
161-
<div
162-
data-testid={`dateHeader`}
163-
className={className}
164-
{...getRootProps({ style })}
165-
>
166-
{intervals.map(interval => {
167-
const intervalText = getLabelFormat(
168-
[interval.startTime, interval.endTime],
169-
unit,
170-
interval.labelWidth
171-
)
172-
return (
173-
<Interval
174-
key={`label-${interval.startTime.valueOf()}`}
175-
unit={unit}
176-
interval={interval}
177-
showPeriod={showPeriod}
178-
intervalText={intervalText}
179-
primaryHeader={unitProp === 'primaryHeader'}
180-
getIntervalProps={getIntervalProps}
181-
intervalRenderer={intervalRenderer}
182-
headerData={restData}
183-
/>
184-
)
185-
})}
186-
</div>
187-
)
188-
}
189-
190146
function formatLabel(
191147
[timeStart, timeEnd],
192148
unit,

0 commit comments

Comments
 (0)