UNPKG

1.26 kBJavaScriptView Raw
1import React from 'react';
2import { render, screen } from '@testing-library/react';
3import { Card } from '..';
4import {
5 testForCustomClass,
6 testForCustomTag,
7 testForDefaultClass,
8} from '../testUtils';
9
10describe('Card', () => {
11 it('should render with "card" class', () => {
12 testForDefaultClass(Card, 'card');
13 });
14
15 it('should render with "bg-primary" class', () => {
16 render(
17 <Card inverse body color="primary">
18 Yo!
19 </Card>,
20 );
21
22 expect(screen.getByText('Yo!')).toHaveClass(
23 'card card-body bg-primary text-white',
24 );
25 });
26
27 it('should render with "outline" class when a color is provided', () => {
28 render(
29 <Card outline body color="primary">
30 Yo!
31 </Card>,
32 );
33
34 expect(screen.getByText('Yo!')).toHaveClass(
35 'card card-body border-primary',
36 );
37 });
38
39 it('should not render with "outline" class when a color is not provided (no default)', () => {
40 render(
41 <Card outline body>
42 Yo!
43 </Card>,
44 );
45
46 expect(screen.getByText('Yo!').className).not.toMatch(/border/i);
47 });
48
49 it('should render additional classes', () => {
50 testForCustomClass(Card);
51 });
52
53 it('should render custom tag', () => {
54 testForCustomTag(Card);
55 });
56});