UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

55 lines 1.37 kB
import React from 'react'; import { mount } from 'enzyme'; import assert from 'assert'; import DraggableLineChart from './DraggableLineChart'; describe('DraggableLineChart', function () { var wrapper; afterEach(function () { if (wrapper) { wrapper.unmount(); } }); describe('render', function () { it('should render an svg chart', function () { wrapper = mount( /*#__PURE__*/React.createElement(DraggableLineChart, { data: [{ x: new Date(), y: 1 }, { x: new Date(), y: 2 }, { x: new Date(), y: 3 }] })); assert.equal(wrapper.find('svg').length, 1, 'did not render an svg'); }); }); describe('when props update,', function () { it('should call d3LineChart.updateLineChart', function () { var data = [{ x: '12:00', y: 1 }, { x: '1:00', y: 2 }, { x: '2:00', y: 3 }]; wrapper = mount( /*#__PURE__*/React.createElement(DraggableLineChart, { data: data })); wrapper.instance().d3LineChart.updateLineChart = jest.fn(); data.push({ x: '3:00', y: 6 }); wrapper.setProps({ data: data }); expect(wrapper.instance().d3LineChart.updateLineChart).toBeCalledTimes(1); }); }); });