Slide 71
Slide 71 text
React components are very testable
import React from 'react'
import ListingsDate from './listings-date'
import { mount } from 'enzyme'
describe('ListingsDateComponent', () => {
describe('an event with just a start date', function() {
const event = { event_date: { date: '2016-01-01' } }
const wrapper = mount(React.createElement(ListingsDate, { event }))
it('formats the month correctly', function() {
expect(wrapper.find('.date-block__seg--month').text()).toEqual('Jan')
})
it('formats the day correctly', function() {
expect(wrapper.find('.date-block__seg--day').text()).toEqual('1')
})
it('formats the year correctly', function() {
expect(wrapper.find('.date-block__seg--year').text()).toEqual('2016')
})
})
})