UNPKG

948 BJavaScriptView Raw
1import React from 'react';
2import { render, screen } from '@testing-library/react';
3import { CardImg } from '..';
4import {
5 testForCustomClass,
6 testForCustomTag,
7 testForDefaultClass,
8} from '../testUtils';
9
10describe('CardImg', () => {
11 it('should render with "card-img" class', () => {
12 testForDefaultClass(CardImg, 'card-img');
13 });
14
15 it('should render top class name', () => {
16 render(<CardImg top alt="awesome poster" src="/path/image.png" />);
17
18 expect(screen.getByAltText(/awesome poster/i)).toHaveClass('card-img-top');
19 });
20
21 it('should render bottom class name', () => {
22 render(<CardImg bottom alt="awesome poster" src="/path/image.png" />);
23
24 expect(screen.getByAltText(/awesome poster/i)).toHaveClass(
25 'card-img-bottom',
26 );
27 });
28
29 it('should render custom tag', () => {
30 testForCustomTag(CardImg);
31 });
32
33 it('should render additional classes', () => {
34 testForCustomClass(CardImg);
35 });
36});