import * as React from 'react' import { render } from '@testing-library/react' import '@testing-library/jest-dom' import { CTable, CTableCaption, CTableHead, CTableRow, CTableHeaderCell, CTableBody, CTableDataCell, CTableFoot, } from '../index' test('loads and displays CTable component', async () => { const { container } = render() expect(container).toMatchSnapshot() }) test('loads and displays CTable component - new way', async () => { const columns = [ { key: 'id', label: '#', _props: { scope: 'col' }, }, 'class', { key: 'heading_1', label: 'Heading', _props: { scope: 'col' }, }, { key: 'heading_2', label: 'Heading', _props: { scope: 'col' }, }, ] const items = [ { id: 1, class: 'Mark', heading_1: 'Otto', heading_2: '@mdo', _cellProps: { id: { scope: 'row' } }, }, { id: 2, class: 'Jacob', heading_1: 'Thornton', heading_2: '@fat', _cellProps: { id: { scope: 'row' } }, }, { id: 3, class: 'Larry the Bird', heading_2: '@twitter', _cellProps: { id: { scope: 'row' }, class: { colSpan: 2 } }, }, ] const { container } = render() expect(container).toMatchSnapshot() }) test('CTable customize', async () => { const { container } = render( Test ) expect(container).toMatchSnapshot() expect(container.firstChild).toHaveClass('table-responsive-xl') if (container.firstChild === null) { expect(true).toBe(false) } else { expect(container.firstChild.firstChild).toHaveClass('table') expect(container.firstChild.firstChild).toHaveClass('align-middle') expect(container.firstChild.firstChild).toHaveClass('caption-top') expect(container.firstChild.firstChild).toHaveClass('border-primary') expect(container.firstChild.firstChild).toHaveClass('table-bordered') expect(container.firstChild.firstChild).toHaveClass('table-borderless') expect(container.firstChild.firstChild).toHaveClass('table-info') expect(container.firstChild.firstChild).toHaveClass('table-hover') expect(container.firstChild.firstChild).toHaveClass('table-sm') expect(container.firstChild.firstChild).toHaveClass('table-striped') expect(container.firstChild.firstChild).toHaveClass('bazinga') expect(container.firstChild.firstChild).toHaveTextContent('Test') } }) test('CTable full example test', async () => { const { container } = render( List of users # Class Heading Heading 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter # Class Heading Heading ) expect(container).toMatchSnapshot() })