1
0
mirror of https://github.com/yldio/copilot.git synced 2024-12-05 01:20:08 +02:00
copilot/frontend/test/components/projects.js

69 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-12-20 13:29:54 +02:00
const test = require('ava');
const enzyme = require('enzyme');
const React = require('react');
const create = require('../helpers/create');
const {
render
} = enzyme;
2016-12-20 21:06:02 +02:00
const {
withIntl,
withRouter
} = create;
2016-12-20 13:29:54 +02:00
test('renders <Projects> without exploding', (t) => {
2016-12-20 21:06:02 +02:00
const Projects = require('@containers/projects').WrappedComponent;
const wrapper = render(withIntl(<Projects />));
2016-12-20 13:29:54 +02:00
t.deepEqual(wrapper.length, 1);
});
test('renders connected <Projects> without exploding', (t) => {
2016-12-20 21:06:02 +02:00
const Projects = require('@containers/projects');
2016-12-20 13:29:54 +02:00
const wrapper = render(create(<Projects />));
t.deepEqual(wrapper.length, 1);
});
test('renders <Projects>\'s list of projects ', (t) => {
const projects = [{
id: 'forest-foundation-dev',
name: 'Forest Foundation Dev',
plan: '20.05$ per day'
}, {
id: 'forest-foundation-testing',
name: 'Forest Foundation Testing',
plan: '20.05$ per day'
}, {
id: 'forest-foundation-production',
name: 'Forest Foundation Production',
plan: '100.17$ per day'
}];
2016-12-20 21:06:02 +02:00
const Projects = require('@containers/projects').WrappedComponent;
const wrapper = render(withRouter(withIntl(
<Projects projects={projects} />
)));
2016-12-20 13:29:54 +02:00
const empty = wrapper.find('p[name=empty]');
const ul = wrapper.find('ul[name=projects]');
const li = ul.find('li');
t.deepEqual(wrapper.length, 1);
t.deepEqual(li.length, projects.length);
t.deepEqual(empty.length, 0);
});
test('renders <Projects>\'s empty <p> when no projects ', (t) => {
2016-12-20 21:06:02 +02:00
const Projects = require('@containers/projects').WrappedComponent;
const wrapper = render(withIntl(<Projects />));
2016-12-20 13:29:54 +02:00
const empty = wrapper.find('p[name=empty]');
const ul = wrapper.find('ul[name=projects]');
const li = ul.find('li');
t.deepEqual(wrapper.length, 1);
t.deepEqual(li.length, 0);
t.deepEqual(empty.length, 1);
});