Skip to content

Commit

Permalink
feat(Table): create component
Browse files Browse the repository at this point in the history
  • Loading branch information
bramvanhoutte committed Jul 25, 2020
1 parent 19de404 commit c710bd5
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 3 deletions.
47 changes: 47 additions & 0 deletions src/components/Table/Table.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import { render } from '@testing-library/react';

import Table from './Table';

interface Course {
name: string;
length: string;
status: 'done' | 'in progress' | 'not started';
}

describe('Table', () => {
const courses: Course[] = [
{ name: 'Course 1', length: '2h', status: 'done' },
{ name: 'Course 2', length: '4h', status: 'in progress' },
{ name: 'Course 3', length: '1h', status: 'in progress' },
{ name: 'Course 4', length: '3h 43m', status: 'not started' },
{ name: 'Course 5', length: '1h', status: 'in progress' },
{ name: 'Course 6', length: '2h 15m', status: 'not started' },
{ name: 'Course 7', length: '3h', status: 'done' },
];

test('default snapshot', () => {
const component = (
<Table>
<Table.Header>
<Table.HeaderCell>Course</Table.HeaderCell>
<Table.HeaderCell>Length</Table.HeaderCell>
<Table.HeaderCell>Status</Table.HeaderCell>
</Table.Header>
<Table.Body>
{courses.map((course) => {
return (
<Table.Row>
<Table.Cell>{course.name}</Table.Cell>
<Table.Cell>{course.length}</Table.Cell>
<Table.Cell>{course.status}</Table.Cell>
</Table.Row>
);
})}
</Table.Body>
</Table>
);
const { asFragment } = render(component);
expect(asFragment()).toMatchSnapshot();
});
});
3 changes: 0 additions & 3 deletions src/components/Table/TableBody/TableBody.module.css

This file was deleted.

Empty file.
170 changes: 170 additions & 0 deletions src/components/Table/__snapshots__/Table.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Table default snapshot 1`] = `
<DocumentFragment>
<table
class="ventura table"
>
<thead
class="header"
>
<tr
class="headerRow"
>
<th
class="cellAlignLeft headerCell"
>
Course
</th>
<th
class="cellAlignLeft headerCell"
>
Length
</th>
<th
class="cellAlignLeft headerCell"
>
Status
</th>
</tr>
</thead>
<tbody
class="body"
>
<tr
class="row"
>
<td
class="cellAlignLeft cell row"
>
Course 1
</td>
<td
class="cellAlignLeft cell row"
>
2h
</td>
<td
class="cellAlignLeft cell row"
>
done
</td>
</tr>
<tr
class="row"
>
<td
class="cellAlignLeft cell row"
>
Course 2
</td>
<td
class="cellAlignLeft cell row"
>
4h
</td>
<td
class="cellAlignLeft cell row"
>
in progress
</td>
</tr>
<tr
class="row"
>
<td
class="cellAlignLeft cell row"
>
Course 3
</td>
<td
class="cellAlignLeft cell row"
>
1h
</td>
<td
class="cellAlignLeft cell row"
>
in progress
</td>
</tr>
<tr
class="row"
>
<td
class="cellAlignLeft cell row"
>
Course 4
</td>
<td
class="cellAlignLeft cell row"
>
3h 43m
</td>
<td
class="cellAlignLeft cell row"
>
not started
</td>
</tr>
<tr
class="row"
>
<td
class="cellAlignLeft cell row"
>
Course 5
</td>
<td
class="cellAlignLeft cell row"
>
1h
</td>
<td
class="cellAlignLeft cell row"
>
in progress
</td>
</tr>
<tr
class="row"
>
<td
class="cellAlignLeft cell row"
>
Course 6
</td>
<td
class="cellAlignLeft cell row"
>
2h 15m
</td>
<td
class="cellAlignLeft cell row"
>
not started
</td>
</tr>
<tr
class="row"
>
<td
class="cellAlignLeft cell row"
>
Course 7
</td>
<td
class="cellAlignLeft cell row"
>
3h
</td>
<td
class="cellAlignLeft cell row"
>
done
</td>
</tr>
</tbody>
</table>
</DocumentFragment>
`;

0 comments on commit c710bd5

Please sign in to comment.