UNPKG

1.42 kBJavaScriptView Raw
1import React from 'react';
2import { render, screen } from '@testing-library/react';
3import '@testing-library/jest-dom';
4import { Toast } from '..';
5import {
6 testForChildrenInComponent,
7 testForCustomAttribute,
8 testForCustomClass,
9 testForCustomTag,
10 testForDefaultTag,
11} from '../testUtils';
12
13describe('Toast', () => {
14 it('should render children', () => {
15 testForChildrenInComponent(Toast);
16 });
17
18 it('should pass className down', () => {
19 testForCustomClass(Toast);
20 });
21
22 it('should pass other props down', () => {
23 testForCustomAttribute(Toast);
24 });
25
26 it('should have support configurable transitionTimeouts', () => {
27 const transitionProps = (
28 <Toast
29 transition={{
30 timeout: 0,
31 appear: false,
32 enter: false,
33 exit: false,
34 }}
35 >
36 Yo!
37 </Toast>
38 ).props.transition;
39
40 expect(transitionProps.timeout).toEqual(0);
41 expect(transitionProps.appear).toBe(false);
42 expect(transitionProps.enter).toBe(false);
43 expect(transitionProps.exit).toBe(false);
44 });
45
46 it('should use a div tag by default', () => {
47 testForDefaultTag(Toast, 'div');
48 });
49
50 it('should support custom tag', () => {
51 testForCustomTag(Toast, 'p');
52 });
53
54 it('should be empty if not isOpen', () => {
55 const { container } = render(<Toast isOpen={false}>Yo!</Toast>);
56 expect(container.children).toHaveLength(0);
57 });
58});