File size: 954 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/**
 * @jest-environment jsdom
 */
import { render } from '@testing-library/react';
import React from 'react';

import { getAllWidgets } from './__utils__/all-widgets';

describe('rendering', () => {
  const widgets = getAllWidgets();

  describe('className', () => {
    test.each(widgets)('sets root class name $name', ({ Component }) => {
      const { container } = render(
        <Component className="BASECLASS" classNames={{ root: 'ROOTCLASS' }} />
      );

      expect(
        container.querySelector('.BASECLASS')!.classList.contains('ROOTCLASS')
      ).toEqual(true);
    });
  });

  describe('root element props', () => {
    test.each(widgets)('set root html attribute $name', ({ Component }) => {
      const { container } = render(
        <Component className="BASECLASS" title="test title" />
      );

      expect(container.querySelector<HTMLDivElement>('.BASECLASS')!.title).toBe(
        'test title'
      );
    });
  });
});