This commit is contained in:
Ying Zhao 2018-01-05 16:09:13 -08:00
Родитель 0d485c5ed8
Коммит 51702c298f
2 изменённых файлов: 30 добавлений и 3 удалений

Просмотреть файл

@ -30,7 +30,7 @@ export const Event = ({
animationDuration: '30s',
animationDelay: -(moment().diff(event.timeReceived, 'seconds')) + 's'
} : {}
const isAllPlaybookInfoAvailable = actions && Array.isArray(actions) && actions.length > 0
const isAllPlaybookInfoAvailable = !!(actions && Array.isArray(actions) && actions.length > 0)
return eventTypeIsFetching && !eventHasValidDisplayText(event)
? LoadingMessage('Fetching Event Type Information', eventTypeActions.fetchEventType(eventTypeId))

Просмотреть файл

@ -2,7 +2,7 @@
import { expect } from 'chai'
import React from 'react'
import createComponent from '../../helpers/shallowRenderHelper'
import { Event } from '../../../src/components/Timeline/Event'
import { Event, mapStateToEventProps } from '../../../src/components/Timeline/Event'
import BootstrapPlaybook from '../../../src/components/Timeline/Playbook/BootstrapPlaybook'
import { Card, CardActions, CardHeader, CardText } from 'material-ui/Card'
import moment from 'moment'
@ -23,8 +23,35 @@ describe('Event', function test () {
})
it('Should render a div containing BootstrapPlaybook and a Card', () => {
expect(this.output.type).to.equal('div')
expect(this.output.type).to.equal('div')
expect(this.output.props.children[0].type).to.equal(BootstrapPlaybook)
expect(this.output.props.children[1].type).to.equal(Card)
})
describe('Card', () => {
it('When there is no action it does not display CardText', () => {
let props = {
text: 'test text',
id: 1,
time: moment(),
actions: []
}
let eventComponent = createComponent(Event, props)
expect(eventComponent.props.children[1].props.children[1]).to.eql(false)
})
it('When actions are present it displays CardText', () => {
let props = {
text: 'test text',
id: 1,
time: moment(),
actions: ['dolphin']
}
let eventComponent = createComponent(Event, props)
expect(eventComponent.props.children[1].props.children[1].type).to.eql(CardText)
})
})
})