generated from wednesday-solutions/react-template
-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.test.js
35 lines (30 loc) · 992 Bytes
/
index.test.js
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
/**
*
* Tests for T
*
*/
import React from 'react';
import { renderWithIntl, getComponentStyles } from '@utils/testUtils';
import { T } from '../index';
describe('<T /> component tests', () => {
it('should render and match the snapshot', () => {
const { baseElement } = renderWithIntl(<T />);
expect(baseElement).toMatchSnapshot();
});
it('should contain 1 T component', () => {
const { getAllByTestId } = renderWithIntl(<T />);
expect(getAllByTestId('t').length).toBe(1);
});
it('should contain render the text according to the id', () => {
const { getAllByText } = renderWithIntl(<T id="repo_list" />);
expect(getAllByText(/Repository List/).length).toBe(1);
});
it('should have a margin-bottom of 5px when we pass marginBottom as 5', () => {
const props = {
marginBottom: 5,
id: 'repo_list'
};
const styles = getComponentStyles(T, props);
expect(styles['margin-bottom']).toBe(`${props.marginBottom}px`);
});
});