1 | import React from 'react';
|
2 | import { render, screen } from '@testing-library/react';
|
3 | import '@testing-library/jest-dom';
|
4 | import { Placeholder } from '..';
|
5 | import { testForDefaultClass } from '../testUtils';
|
6 |
|
7 | describe('Placeholder', () => {
|
8 | it('should render with "placeholder" class', () => {
|
9 | testForDefaultClass(Placeholder, 'placeholder');
|
10 | });
|
11 |
|
12 | it('should render column size', () => {
|
13 | render(<Placeholder data-testid="test" xs={7} />);
|
14 | expect(screen.getByTestId('test')).toHaveClass('col-7');
|
15 | });
|
16 |
|
17 | it('should render animation', () => {
|
18 | render(<Placeholder data-testid="test" tag="p" animation="glow" />);
|
19 | expect(screen.getByTestId('test')).toHaveClass('placeholder-glow');
|
20 | });
|
21 |
|
22 | it('should render color', () => {
|
23 | render(<Placeholder data-testid="test" xs={12} color="primary" />);
|
24 | expect(screen.getByTestId('test')).toHaveClass('bg-primary');
|
25 | });
|
26 |
|
27 | it('should render size', () => {
|
28 | render(<Placeholder data-testid="test" size="lg" xs={12} />);
|
29 | expect(screen.getByTestId('test')).toHaveClass('placeholder-lg');
|
30 | });
|
31 |
|
32 | it('should render different widths for different breakpoints', () => {
|
33 | render(<Placeholder data-testid="test" size="lg" xs={12} lg={8} />);
|
34 | const node = screen.getByTestId('test');
|
35 | expect(node).toHaveClass('col-lg-8');
|
36 | expect(node).toHaveClass('col-12');
|
37 | });
|
38 |
|
39 | it('should allow custom columns to be defined', () => {
|
40 | render(
|
41 | <Placeholder
|
42 | data-testid="test"
|
43 | widths={['base', 'jumbo']}
|
44 | base="4"
|
45 | jumbo="6"
|
46 | />,
|
47 | );
|
48 | const node = screen.getByTestId('test');
|
49 | expect(node).toHaveClass('col-4');
|
50 | expect(node).toHaveClass('col-jumbo-6');
|
51 | });
|
52 |
|
53 | it('should allow custom columns to be defined with objects', () => {
|
54 | render(
|
55 | <Placeholder
|
56 | data-testid="test"
|
57 | widths={['base', 'jumbo', 'custom']}
|
58 | custom={{ size: 1, order: 2, offset: 4 }}
|
59 | />,
|
60 | );
|
61 | const node = screen.getByTestId('test');
|
62 | expect(node).toHaveClass('col-custom-1');
|
63 | expect(node).toHaveClass('order-custom-2');
|
64 | expect(node).toHaveClass('offset-custom-4');
|
65 | expect(node).not.toHaveClass('col');
|
66 | });
|
67 | });
|