/
caption.test.tsx
37 lines (32 loc) · 1.13 KB
/
caption.test.tsx
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
import React from 'react';
import { create } from 'react-test-renderer';
import 'jest-styled-components';
import { sportsbetDark, ThemeProvider } from '@heathmont/moon-themes';
import Caption from '../Caption';
const renderWithTheme = (component: JSX.Element) => (
<ThemeProvider theme={sportsbetDark}>{component}</ThemeProvider>
);
describe('Caption', () => {
describe('Elements', () => {
test('renders as <span> by default', () => {
const caption = create(renderWithTheme(<Caption>Caption</Caption>));
expect(caption).toMatchSnapshot();
});
test('renders as an element if "as" prop provided', () => {
const text = create(
renderWithTheme(<Caption as="p">Caption with Paragraph tag</Caption>)
);
expect(text).toMatchSnapshot();
});
});
test('renders default color', () => {
const caption = create(renderWithTheme(<Caption>Caption</Caption>));
expect(caption).toMatchSnapshot();
});
test('renders with a color', () => {
const caption = create(
renderWithTheme(<Caption color="piccolo.100">Caption</Caption>)
);
expect(caption).toMatchSnapshot();
});
});