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) => {
|
2017-03-29 15:45:18 +03:00
|
|
|
const Projects =
|
|
|
|
require('@containers/projects/list').default.WrappedComponent;
|
2017-03-23 14:03:45 +02:00
|
|
|
const wrapper = render(withRouter(withIntl(<Projects />)));
|
2016-12-20 13:29:54 +02:00
|
|
|
t.deepEqual(wrapper.length, 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('renders connected <Projects> without exploding', (t) => {
|
2017-03-29 15:45:18 +03:00
|
|
|
const Projects =
|
|
|
|
require('@containers/projects/list').default;
|
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'
|
|
|
|
}];
|
|
|
|
|
2017-03-29 15:45:18 +03:00
|
|
|
const Projects =
|
|
|
|
require('@containers/projects/list').default.WrappedComponent;
|
2016-12-20 21:06:02 +02:00
|
|
|
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) => {
|
2017-03-29 15:45:18 +03:00
|
|
|
const Projects =
|
|
|
|
require('@containers/projects/list').default.WrappedComponent;
|
2017-03-23 14:03:45 +02:00
|
|
|
const wrapper = render(withRouter(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);
|
|
|
|
});
|