UNPKG

1.73 kBJSXView Raw
1const React = require('react');
2const { expect } = require('chai');
3const { shallow } = require('enzyme');
4const { DateValue } = require('../');
5
6describe('<DateValue />', () => {
7 describe('without a timezone', function() {
8 const date = new Date('2016-01-01 12:00:00');
9 const component = shallow(<DateValue type="Date" value={date} />);
10
11 it('sets the base class', () => {
12 expect(component.hasClass('element-value')).to.equal(true);
13 });
14
15 it('sets the type class', () => {
16 expect(component.hasClass('element-value-is-date')).to.equal(true);
17 });
18
19 it('sets the title', () => {
20 expect(component.props().title).to.contain('2016-01-01');
21 });
22
23 it('sets the date value', () => {
24 expect(component.text()).to.contain('2016-01-01');
25 });
26
27 it('sets the time value', () => {
28 expect(component.text()).to.contain('12:00:00');
29 });
30 });
31
32 describe('with a timezone', function() {
33 const date = new Date(1451667600000);
34 const component = shallow(<DateValue type="Date" value={date} tz={'UTC'} />);
35
36 it('sets the base class', () => {
37 expect(component.hasClass('element-value')).to.equal(true);
38 });
39
40 it('sets the type class', () => {
41 expect(component.hasClass('element-value-is-date')).to.equal(true);
42 });
43
44 it('sets the title', () => {
45 expect(component.props().title).to.contain('2016-01-01');
46 });
47
48 it('sets the date value', () => {
49 expect(component.text()).to.contain('2016-01-01');
50 });
51
52 it('sets the time value', () => {
53 expect(component.text()).to.contain('17:00:00');
54 });
55
56 it('includes the timezone', () => {
57 expect(component.text()).to.contain('+00:00');
58 });
59 });
60});