import {mount} from 'enzyme'; import React from 'react'; import {ProjectCard} from 'app/views/projectsDashboard/projectCard'; // NOTE: Unmocking debounce so that the actionCreator never fires jest.unmock('lodash/debounce'); describe('ProjectCard', function() { let wrapper; beforeEach(function() { wrapper = mount( , TestStubs.routerContext() ); }); afterEach(function() { MockApiClient.clearMockResponses(); }); it('renders', function() { expect(wrapper).toMatchSnapshot(); }); it('renders latest 2 deploys', function() { const latestDeploys = [ { environment: 'beta', dateFinished: '2018-05-10T20:56:40.092Z', version: '123456', }, { environment: 'staging', dateFinished: '2018-05-08T20:56:40.092Z', version: '789789', }, { environment: 'production', dateFinished: '2018-05-09T20:56:40.092Z', version: '123123', }, ]; wrapper = mount( , TestStubs.routerContext() ); expect(wrapper.find('Deploy')).toHaveLength(2); expect(wrapper.find('NoDeploys')).toHaveLength(0); expect(wrapper.find('Environment[children="beta"]')).toHaveLength(1); expect(wrapper.find('Environment[children="production"]')).toHaveLength(1); expect(wrapper.find('Environment[children="staging"]')).toHaveLength(0); }); it('renders empty state if no deploys', function() { expect(wrapper.find('NoDeploys')).toHaveLength(1); }); it('renders with platform', function() { expect(wrapper.find('PlatformList')).toHaveLength(1); const icons = wrapper.find('StyledPlatformIcon'); expect(icons.first().prop('platform')).toBe('javascript'); }); it('renders loading placeholder card if there are no stats', function() { wrapper = mount( , TestStubs.routerContext() ); expect(wrapper.find('LoadingCard')).toHaveLength(1); }); });