-
Notifications
You must be signed in to change notification settings - Fork 51
/
DateAndTimeDisplay.test.js
33 lines (30 loc) · 1.04 KB
/
DateAndTimeDisplay.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* global jest describe it expect */
jest.disableAutomock()
import React from 'react'
import ReactDOMServer from 'react-dom/server'
import DateAndTimeDisplay from '.'
import { addLocaleData, IntlProvider } from 'react-intl'
import { locale, formats } from '../../config/intl'
import Icon from '../../../components/Icon'
// Set up locale so formats will work properly
addLocaleData({
locale: 'en-US'
})
describe('DateAndTimeDisplay Test', () => {
it('can render markup', () => {
const dateTime = new Date(1985, 9, 26, 1, 21)
// <IntlProvider> is at the top level of the app
const actual = ReactDOMServer.renderToStaticMarkup(
<IntlProvider locale={locale} formats={formats}>
<DateAndTimeDisplay dateTime={dateTime} className="marty" />
</IntlProvider>)
const expected = ReactDOMServer.renderToStaticMarkup(
<span className="marty">
<Icon name="clock" className="n1" />
<span>Oct 26, 1985</span>
<span>1:21 AM</span>
</span>
)
expect(actual).toEqual(expected)
})
})