Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

Commit

Permalink
simple unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Lavigne committed Sep 9, 2016
1 parent 16a06a8 commit 2d356ec
Showing 1 changed file with 68 additions and 2 deletions.
70 changes: 68 additions & 2 deletions src/routes/Dashboard/components/Map/Map.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,71 @@
import React from 'react';
import test from 'ava';
import { shallow } from 'enzyme';
import Map from './Map';

test('(Component) Has expected elements.', t => {
t.true(true);
const testDistributionCenters = [
{
address: {
city: 'Salt Lake City',
state: 'Utah',
country: 'US',
latitude: 40.71,
longitude: -111.90,
},
contact: {
name: 'Joseph Smith',
},
},
];

const testRetailers = [
{
address: {
city: 'Memphis',
state: 'Tennessee',
country: 'US',
latitude: 35.19,
longitude: -90.02,
},
contact: {
name: 'Joseph Smith',
},
},
];

const testShipments = [
{
status: 'IN_TRANSIT',
fromId: '3',
toId: '204',
currentLocation: {
city: 'Albany',
state: 'New York',
country: 'US',
latitude: 42.65,
longitude: -73.75,
},
estimatedTimeOfArrival: 'Thu, 28 Oct 2016',
updatedAt: 'Thu, 27 Oct 2016 12:15:37 GMT',
},
];

const setup = (someProps) => {
const props = someProps;
const component = shallow(<Map {...props} />);
return { component, props };
};

test('(Component) Has no markers by default.', t => {
const { component } = setup({});
t.is(component.find('MapMarker').length, 0);
});

test('(Component) Has no markers by default.', t => {
const { component } = setup({
distributionCenters: testDistributionCenters,
retailers: testRetailers,
shipments: testShipments,
});
t.is(component.find('MapMarker').length, 3);
});

0 comments on commit 2d356ec

Please sign in to comment.