forked from AdaGold/react-chatlog
-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathChatLog.test.js
More file actions
63 lines (58 loc) · 1.42 KB
/
ChatLog.test.js
File metadata and controls
63 lines (58 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React from 'react';
import '@testing-library/jest-dom/extend-expect';
import ChatLog from './ChatLog.js';
import { render, screen } from '@testing-library/react';
const LOG = [
{
sender: 'Vladimir',
body: 'why are you arguing with me',
timeStamp: '2018-05-29T22:49:06+00:00',
},
{
sender: 'Estragon',
body: 'Because you are wrong.',
timeStamp: '2018-05-29T22:49:33+00:00',
},
{
sender: 'Vladimir',
body: 'because I am what',
timeStamp: '2018-05-29T22:50:22+00:00',
},
{
sender: 'Estragon',
body: 'A robot.',
timeStamp: '2018-05-29T22:52:21+00:00',
},
{
sender: 'Vladimir',
body: 'Notabot',
timeStamp: '2019-07-23T22:52:21+00:00',
},
];
describe('Wave 02: ChatLog', () => {
beforeEach(() => {
render(<ChatLog entries={LOG} />);
});
test('renders without crashing and shows all the names', () => {
[
{
name: 'Vladimir',
numChats: 3,
},
{
name: 'Estragon',
numChats: 2,
},
].forEach((person) => {
const elementList = screen.getAllByText(new RegExp(person.name));
expect(elementList.length).toEqual(person.numChats);
elementList.forEach((element) => {
expect(element).toBeInTheDocument();
});
});
});
test('renders an empty list without crashing', () => {
const element = render(<ChatLog entries={[]} />);
expect(element).not.toBeNull();
});
});