1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- 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(
- <ProjectCard
- organization={TestStubs.Organization()}
- project={TestStubs.Project({
- stats: [[1525042800, 1], [1525046400, 2]],
- platform: 'javascript',
- })}
- params={{orgId: 'org-slug'}}
- />,
- 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(
- <ProjectCard
- organization={TestStubs.Organization()}
- project={TestStubs.Project({
- stats: [[1525042800, 1], [1525046400, 2]],
- platform: 'javascript',
- latestDeploys,
- })}
- params={{orgId: 'org-slug'}}
- />,
- 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(
- <ProjectCard
- organization={TestStubs.Organization()}
- project={TestStubs.Project()}
- params={{orgId: 'org-slug'}}
- />,
- TestStubs.routerContext()
- );
- expect(wrapper.find('LoadingCard')).toHaveLength(1);
- });
- });
|