/* eslint object-curly-newline: 0 */
import React from 'react';
import { mount } from 'enzyme';
import { expect } from 'chai';
import { describe, it, specs } from '../../storybook/facade';
import Table from './index';
import Tooltip from '../Tooltip';

export default (stories) => {
	stories.add('Table', () => {
		const columns = [{
			title: 'Name',
			accessor: 'name',
			type: Table.TYPE.ELEMENT,
			cell: row => (
				<>
					{row.name}
					<span>
						{row.title}
					</span>
				</>
			)
		}, {
			title: 'Company',
			accessor: 'company'
		}, {
			title: 'Grouped Header',
			columns: [{
				title: 'Hire Date',
				accessor: 'date',
				type: Table.TYPE.DATE,
				format: 'll'
			}, {
				title: 'Experience (Years)',
				accessor: 'experience',
				type: Table.TYPE.NUMBER,
				format: '0,0',
				tooltip: children => (
					<Tooltip header="The number of years experience this employee has in their field">
						{children}
					</Tooltip>
				)
			}]
		}];

		const data = [
			{ name: 'Berenice Van Hault', company: 'Zooveo', title: 'Senior Financial Analyst', date: 1448147351000, location: 'Russia', experience: 11 },
			{ name: 'Kynthia Galtone', company: 'Flashpoint', title: 'Director of Sales', date: 1375333911000, location: 'Slovenia', experience: 11 },
			{ name: 'Eryn Hearon', company: 'Riffpath', title: 'Information Systems Manager', date: 1506602990000, location: 'Serbia', experience: 18 },
			{ name: 'Amalia Kuhle', company: 'Thoughtblab', title: 'Structural Engineer', date: 1525974027000, location: 'Libya', experience: 15 },
			{ name: 'Hashim Bleacher', company: 'Oloo', title: 'Statistician II', date: 1396367957000, location: 'Malawi', experience: 5 },
			{ name: 'Merl Domleo', company: 'Jabberstorm', title: 'Physical Therapy Assistant', date: 1354554882000, location: 'Indonesia', experience: 13 },
			{ name: 'Malia Castree', company: 'Babbleset', title: 'VP Marketing', date: 1541256581000, location: 'Swaziland', experience: 9 },
			{ name: 'Norina Juara', company: 'Trudeo', title: 'Software Engineer IV', date: 1442827879000, location: 'Portugal', experience: 1 },
			{ name: 'Constantine Gleadle', company: 'Livetube', title: 'Software Test Engineer I', date: 1474899212000, location: 'Macedonia', experience: 13 },
			{ name: 'Danit Zaniolo', company: 'Blogspan', title: 'Design Engineer', date: 1296722737000, location: 'Dominican Republic', experience: 10 },
			{ name: 'Abdul Bodycote', company: 'Meetz', title: 'Nurse Practicioner', date: 1421293342000, location: 'Albania', experience: 17 },
			{ name: 'Juliann Galliard', company: 'Ntags', title: 'Product Engineer', date: 1379857594000, location: 'Thailand', experience: 4 },
			{ name: 'Katharyn Assaf', company: 'Camimbo', title: 'Civil Engineer', date: 1332645267000, location: 'Argentina', experience: 8 },
			{ name: 'Nickolas Mytton', company: 'Riffpedia', title: 'Physical Therapy Assistant', date: 1307949820000, location: 'China', experience: 13 },
			{ name: 'Garrek Wrankling', company: 'Riffwire', title: 'Analog Circuit Design Manager', date: 1447204345000, location: 'United States', experience: 18 },
			{ name: 'Brianna MacCarlich', company: 'Flipstorm', title: 'Help Desk Operator', date: 1530343267000, location: 'Philippines', experience: 10 },
			{ name: 'George Sheaber', company: 'Devshare', title: 'Administrative Assistant II', date: 1510156772000, location: 'Yemen', experience: 1 },
			{ name: 'Findlay Garfirth', company: 'Tagchat', title: 'Software Test Engineer I', date: 1529569958000, location: 'Japan', experience: 3 },
			{ name: 'Drugi De Fries', company: 'Innojam', title: 'Health Coach III', date: 1444929397000, location: 'Russia', experience: 6 },
			{ name: 'Park Fulcher', company: 'Jabberstorm', title: 'Pharmacist', date: 1500085482000, location: 'Portugal', experience: 16 },
			{ name: 'Gayler Alliberton', company: 'Trilia', title: 'Occupational Therapist', date: 1277975381000, location: 'Norway', experience: 3 },
			{ name: 'Debora Beales', company: 'Gigashots', title: 'Research Associate', date: 1395755477000, location: 'Bangladesh', experience: 10 },
			{ name: 'Nerita Tingey', company: 'Realblab', title: 'Data Coordiator', date: 1295352494000, location: 'China', experience: 14 },
			{ name: 'Wesley Harfleet', company: 'Topdrive', title: 'Media Manager IV', date: 1519699813000, location: 'Peru', experience: 16 },
			{ name: 'Cleon Le Pruvost', company: 'Zoozzy', title: 'Senior Financial Analyst', date: 1485022477000, location: 'Qatar', experience: 12 },
			{ name: 'Arty Suller', company: 'Fivebridge', title: 'General Manager', date: 1270631516000, location: 'Ukraine', experience: 6 },
			{ name: 'Graham Ewdale', company: 'Twimbo', title: 'Research Associate', date: 1375652523000, location: 'Belarus', experience: 3 },
			{ name: 'Wilburt Traves', company: 'Skibox', title: 'Database Administrator I', date: 1279992230000, location: 'Norway', experience: 3 },
			{ name: 'Lamont Edgeson', company: 'Zava', title: 'Desktop Support Technician', date: 1414589648000, location: 'Poland', experience: 17 },
			{ name: 'Jude Lacy', company: 'Realpoint', title: 'Senior Developer', date: 1490870099000, location: 'Liberia', experience: 10 },
			{ name: 'Benedikta Drain', company: 'Oozz', title: 'Environmental Specialist', date: 1437602070000, location: 'Philippines', experience: 19 },
			{ name: 'Trixy Tytcomb', company: 'Youopia', title: 'Mechanical Systems Engineer', date: 1270694157000, location: 'Vietnam', experience: 6 },
			{ name: 'Hermon Chucks', company: 'Shufflester', title: 'Marketing Assistant', date: 1454981461000, location: 'Indonesia', experience: 12 },
			{ name: 'Pebrook Dyet', company: 'Demimbu', title: 'Civil Engineer', date: 1311857548000, location: 'France', experience: 5 },
			{ name: 'North Halleybone', company: 'Katz', title: 'Speech Pathologist', date: 1286174165000, location: 'Indonesia', experience: 7 },
			{ name: 'Bobinette Pedwell', company: 'Brainlounge', title: 'Cost Accountant', date: 1513161265000, location: 'China', experience: 4 },
			{ name: 'Emelita Jeff', company: 'Gabcube', title: 'Data Coordiator', date: 1338907152000, location: 'Nigeria', experience: 16 },
			{ name: 'Jemimah Bassilashvili', company: 'Trilith', title: 'Mechanical Systems Engineer', date: 1384383418000, location: 'Brazil', experience: 16 },
			{ name: 'Collie Cottrill', company: 'Feedfire', title: 'Mechanical Systems Engineer', date: 1499011656000, location: 'Sweden', experience: 10 },
			{ name: 'Hamil Lanbertoni', company: 'Linkbridge', title: 'Office Assistant III', date: 1375386337000, location: 'France', experience: 16 },
			{ name: 'Corliss Dadge', company: 'Yadel', title: 'Account Executive', date: 1285127483000, location: 'Indonesia', experience: 11 },
			{ name: 'Adda O\'Concannon', company: 'Voonix', title: 'Analyst Programmer', date: 1451010213000, location: 'Indonesia', experience: 1 },
			{ name: 'Mari Kenyam', company: 'Tagtune', title: 'Office Assistant III', date: 1460718990000, location: 'Vietnam', experience: 1 },
			{ name: 'Jessey Gwilliam', company: 'Yata', title: 'Registered Nurse', date: 1397760727000, location: 'Luxembourg', experience: 3 },
			{ name: 'Aeriell Iddon', company: 'Skimia', title: 'Assistant Manager', date: 1500182495000, location: 'Philippines', experience: 2 },
			{ name: 'Allan Benech', company: 'Quimba', title: 'Dental Hygienist', date: 1486600082000, location: 'Russia', experience: 1 },
			{ name: 'Dorthy Debenham', company: 'Devpulse', title: 'Engineer III', date: 1483876806000, location: 'Indonesia', experience: 17 },
			{ name: 'Hayyim Hess', company: 'Skiba', title: 'Budget/Accounting Analyst I', date: 1288853178000, location: 'Portugal', experience: 13 },
			{ name: 'Melosa Tolotti', company: 'Kazio', title: 'Civil Engineer', date: 1302819795000, location: 'Chile', experience: 4 },
			{ name: 'Enrico Lilie', company: 'DabZ', title: 'Physical Therapy Assistant', date: 1304383655000, location: 'Mexico', experience: 17 },
			{ name: 'Linnea Jilliss', company: 'Trilith', title: 'Health Coach III', date: 1294601068000, location: 'China', experience: 11 },
			{ name: 'Fayth Gauntlett', company: 'Voonte', title: 'Teacher', date: 1488431340000, location: 'Bulgaria', experience: 9 },
			{ name: 'Janelle Skala', company: 'Yodo', title: 'Help Desk Operator', date: 1379237812000, location: 'Albania', experience: 11 },
			{ name: 'Corey Lorens', company: 'Skynoodle', title: 'Software Engineer IV', date: 1321817595000, location: 'Colombia', experience: 12 },
			{ name: 'Pansy O\'Kennavain', company: 'Jabberbean', title: 'Actuary', date: 1388219274000, location: 'China', experience: 15 },
			{ name: 'Andras Jagielski', company: 'Skilith', title: 'Food Chemist', date: 1438915560000, location: 'Vietnam', experience: 17 },
			{ name: 'Constancy McClay', company: 'Skyble', title: 'Operator', date: 1381929180000, location: 'Russia', experience: 0 },
			{ name: 'Hillie Jilkes', company: 'Dazzlesphere', title: 'Biostatistician III', date: 1413235181000, location: 'Kenya', experience: 16 },
			{ name: 'Clemente Rzehor', company: 'Kwimbee', title: 'Teacher', date: 1527987073000, location: 'Indonesia', experience: 15 },
			{ name: 'Stan Tingly', company: 'Quimba', title: 'Senior Financial Analyst', date: 1483005313000, location: 'Portugal', experience: 6 },
			{ name: 'Willette Cass', company: 'Aibox', title: 'Nuclear Power Engineer', date: 1527934751000, location: 'Ethiopia', experience: 3 },
			{ name: 'Francine Bonsey', company: 'Zoomcast', title: 'Quality Engineer', date: 1478918126000, location: 'Indonesia', experience: 17 },
			{ name: 'Mycah Linck', company: 'Tagopia', title: 'Engineer I', date: 1295610508000, location: 'Philippines', experience: 7 },
			{ name: 'Clevey Chishull', company: 'Rhynoodle', title: 'Mechanical Systems Engineer', date: 1332853126000, location: 'Argentina', experience: 5 },
			{ name: 'Weylin Sidnell', company: 'Tazzy', title: 'Physical Therapy Assistant', date: 1503074456000, location: 'Vietnam', experience: 15 },
			{ name: 'Brenden Swanbourne', company: 'Thoughtstorm', title: 'Quality Engineer', date: 1495337484000, location: 'Portugal', experience: 16 },
			{ name: 'Nye Conkling', company: 'Jaloo', title: 'Clinical Specialist', date: 1499307123000, location: 'Philippines', experience: 3 },
			{ name: 'Brandice Crosoer', company: 'Yotz', title: 'Biostatistician II', date: 1470789964000, location: 'Poland', experience: 20 },
			{ name: 'Gilly Skaife d\'Ingerthorpe', company: 'Roomm', title: 'Health Coach III', date: 1447865199000, location: 'China', experience: 13 },
			{ name: 'Ursulina Tew', company: 'Jaloo', title: 'Financial Advisor', date: 1500119624000, location: 'Kazakhstan', experience: 6 },
			{ name: 'Tiffi Prose', company: 'Aimbo', title: 'Biostatistician I', date: 1341131402000, location: 'Indonesia', experience: 13 },
			{ name: 'Agace Rowan', company: 'Twinte', title: 'Legal Assistant', date: 1258224552000, location: 'Mongolia', experience: 4 },
			{ name: 'Granny Skedge', company: 'Oozz', title: 'Developer I', date: 1347606909000, location: 'Philippines', experience: 8 },
			{ name: 'Ringo Tremelling', company: 'Zoozzy', title: 'Data Coordiator', date: 1507610963000, location: 'China', experience: 0 },
			{ name: 'Kane Cellone', company: 'Zoozzy', title: 'Compensation Analyst', date: 1282268048000, location: 'Nigeria', experience: 4 }
		];

		const component = (
			<div style={{ background: '#FFF' }}>
				<Table
					id="TableTest"
					columns={columns}
					data={data}
					sort={{
						property: 'name',
						value: 'asc'
					}}
					noBorder
				/>
			</div>
		);

		specs(() => describe('Table', () => {
			const wrapper = mount(component);

			it('Should be ok', () => {
				expect(wrapper).be.ok;
			});
		}));

		return component;
	});
};
