UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

52 lines 2.29 kB
import _get from "lodash/get"; import React from 'react'; import { shallow } from 'enzyme'; import assert from 'assert'; import { common } from '../../util/generic-tests'; import ScrollTable from './ScrollTable'; import Table from '../Table/Table'; var Thead = ScrollTable.Thead, Tbody = ScrollTable.Tbody, Tr = ScrollTable.Tr, Th = ScrollTable.Th, Td = ScrollTable.Td; describe('ScrollTable', function () { common(ScrollTable); describe('render', function () { it('should render a container with a Table inside', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(ScrollTable, null)); assert(wrapper.is('.lucid-ScrollTable'), 'root must be a container element'); assert(wrapper.not(Table), 'root must not be a Table'); assert.equal(wrapper.find(Table).length, 1, 'must contain a Table component'); }); }); describe('props', function () { describe('tableWidth', function () { it('should set the width style of the underlying Table component', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(ScrollTable, { tableWidth: 789 })); var tableWrapper = wrapper.find(Table); assert.equal(_get(tableWrapper.prop('style'), 'width'), 789, 'must set Table style.width'); }); }); describe('hasWordWrap', function () { it('should set the `hasWordWrap` props of the underlying Table component', function () { var wrapper = shallow( /*#__PURE__*/React.createElement(ScrollTable, { hasWordWrap: true })); var tableWrapper = wrapper.find(Table); assert.equal(tableWrapper.prop('hasWordWrap'), true, 'must set Table hasWordWrap'); }); }); }); describe('children', function () { it('should match the child elements of the Table component', function () { assert.equal(Thead, Table.Thead, 'Thead child component must match Table.Thead'); assert.equal(Tbody, Table.Tbody, 'Thead child component must match Table.Tbody'); assert.equal(Tr, Table.Tr, 'Thead child component must match Table.Tr'); assert.equal(Th, Table.Th, 'Thead child component must match Table.Th'); assert.equal(Td, Table.Td, 'Thead child component must match Table.Td'); }); }); });