Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Oct 13, 2017
1 parent 377d38c commit c58ed8e
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const styles = {
position: 'relative',
padding: '5px',
borderRadius: '1px',
boxShadow: '0 0 0 1px rgba(0,0,0,.1)',
display: 'inline-block',
cursor: 'pointer',
boxShadow: 'rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset, rgba(0, 0, 0, 0.25) 0px 0px 4px inset',
Expand Down Expand Up @@ -65,7 +64,7 @@ export default class ColorPickerControl extends React.Component {
</Popover>);
}
render() {
const c = this.props.value || { r: 0, g: 0, b:0, a: 0 };
const c = this.props.value || { r: 0, g: 0, b: 0, a: 0 };
const colStyle = Object.assign(
{}, styles.color, { background: `rgba(${c.r}, ${c.g}, ${c.b}, ${c.a})` });
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-disable no-unused-expressions */
import React from 'react';
import { expect } from 'chai';
import { describe, it, beforeEach } from 'mocha';
import { shallow } from 'enzyme';
import { OverlayTrigger } from 'react-bootstrap';
import { SketchPicker } from 'react-color';

import ColorPickerControl from
'../../../../javascripts/explore/components/controls/ColorPickerControl';
import ControlHeader from '../../../../javascripts/explore/components/ControlHeader';

const defaultProps = {
value: { },
};

describe('ColorPickerControl', () => {
let wrapper;
let inst;
beforeEach(() => {
wrapper = shallow(<ColorPickerControl {...defaultProps} />);
inst = wrapper.instance();
});

it('renders a OverlayTrigger', () => {
const controlHeader = wrapper.find(ControlHeader);
expect(controlHeader).to.have.lengthOf(1);
expect(wrapper.find(OverlayTrigger)).to.have.length(1);
});

it('renders a OverlayTrigger', () => {
const controlHeader = wrapper.find(ControlHeader);
expect(controlHeader).to.have.lengthOf(1);
expect(wrapper.find(OverlayTrigger)).to.have.length(1);
});

it('renders a Popover with a SketchPicker', () => {
const popOver = shallow(inst.renderPopover());
expect(popOver.find(SketchPicker)).to.have.lengthOf(1);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* eslint-disable no-unused-expressions */
import React from 'react';
import { expect } from 'chai';
import { describe, it, beforeEach } from 'mocha';
import { mount } from 'enzyme';
import { Creatable } from 'react-select';

import ColorSchemeControl from
'../../../../javascripts/explore/components/controls/ColorSchemeControl';
import { ALL_COLOR_SCHEMES } from '../../../../javascripts/modules/colors';

const defaultProps = {
options: Object.keys(ALL_COLOR_SCHEMES).map(s => ([s, s])),
};

describe('ColorSchemeControl', () => {
let wrapper;
beforeEach(() => {
wrapper = mount(<ColorSchemeControl {...defaultProps} />);
});

it('renders a Creatable', () => {
expect(wrapper.find(Creatable)).to.have.length(1);
});
});

0 comments on commit c58ed8e

Please sign in to comment.