This repository has been archived by the owner on Apr 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test and fixed story book for ShipmentCard by using the unconne…
…cted constructor rather than the default ( import {ShipmentCard} vs import ShipmentCard)
- Loading branch information
Frederic Lavigne
committed
Jan 17, 2017
1 parent
7f963d6
commit e4d1487
Showing
4 changed files
with
113 additions
and
27 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/routes/Dashboard/components/ForecastTile/ForecastTile.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import test from 'ava'; | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import ForecastTile from './ForecastTile'; | ||
|
||
test('(Component) ForecastTile shows progress when no weather.', t => { | ||
const props = { }; | ||
const component = shallow(<ForecastTile {...props} />); | ||
t.is(component.find('LoadingSpinner').length, 1, 'has a loading spinner'); | ||
t.is(component.find('Table').length, 0, 'has no forecasts table'); | ||
}); | ||
|
||
test('(Component) ForecastTile shows table when weather.', t => { | ||
const props = { | ||
weather: { | ||
forecasts: [], | ||
}, | ||
}; | ||
const component = shallow(<ForecastTile {...props} />); | ||
t.is(component.find('LoadingSpinner').length, 0, 'has no loading spinner'); | ||
t.is(component.find('Table').length, 1, 'has a forecasts table'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/routes/Dashboard/components/Map/PopUpCard/ShipmentCard/ShipmentCard.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import test from 'ava'; | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { ShipmentCard } from './ShipmentCard'; | ||
|
||
test('(Component) ShipmentCard shows a progress when no weather data.', t => { | ||
const props = { | ||
shipment: { | ||
toId: 462, | ||
estimatedTimeOfArrival: '2016-10-22T00:00:00.000Z', | ||
status: 'DELIVERED', | ||
updatedAt: '2016-10-20T12:15:37.000Z', | ||
currentLocation: { | ||
state: 'Texas', | ||
latitude: 32.74, | ||
country: 'US', | ||
longitude: -96.8, | ||
city: 'Dallas', | ||
}, | ||
fromId: 2, | ||
deliveredAt: null, | ||
createdAt: '2016-09-08T16:26:16.933Z', | ||
id: 810, | ||
}, | ||
retrieveWeatherObservations: () => {}, | ||
}; | ||
const component = shallow(<ShipmentCard {...props} />); | ||
t.is(component.find('LoadingSpinner').length, 1, 'has a loading spinner'); | ||
}); | ||
|
||
test('(Component) ShipmentCard shows current weather when it exists.', t => { | ||
const props = { | ||
shipment: { | ||
toId: 462, | ||
estimatedTimeOfArrival: '2016-10-22T00:00:00.000Z', | ||
status: 'DELIVERED', | ||
updatedAt: '2016-10-20T12:15:37.000Z', | ||
currentLocation: { | ||
state: 'Texas', | ||
latitude: 32.74, | ||
country: 'US', | ||
longitude: -96.8, | ||
city: 'Dallas', | ||
weather: { | ||
observation: { | ||
wx_phrase: 'Good weather', | ||
}, | ||
}, | ||
}, | ||
fromId: 2, | ||
deliveredAt: null, | ||
createdAt: '2016-09-08T16:26:16.933Z', | ||
id: 810, | ||
}, | ||
retrieveWeatherObservations: () => {}, | ||
}; | ||
const component = shallow(<ShipmentCard {...props} />); | ||
t.true(component.text().indexOf('Good weather') > 0, 'has weather info'); | ||
}); |