Skip to content

Instantly share code, notes, and snippets.

@trevlar
Forked from viceversus/list_wrapper_spec.js
Created November 21, 2017 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevlar/db60cd4f7d4a0f087e129f20d2b941c4 to your computer and use it in GitHub Desktop.
Save trevlar/db60cd4f7d4a0f087e129f20d2b941c4 to your computer and use it in GitHub Desktop.
List Wrapper Spec
import React from 'react';
import "babel-polyfill";
import listWrapper from 'list_wrapper';
import { shallow } from 'enzyme';
describe('ListWrapper', function () {
var wrapper, MockListComponent, instance, set;
beforeEach(function () {
MockListComponent = React.createClass({
render: function () {
return (<div>Fake List</div>);
},
});
set = new Set();
WrapperComponent = listWrapper(MockListComponent);
wrapper = shallow(<WrapperComponent />);
instance = wrapper.instance();
});
it('renders the List Component as the root element', function () {
expect(wrapper.first().is(MockListComponent)).toBeTruthy();
});
describe('handleOnSelect', function () {
describe('when not already selected', function () {
it('adds the key to the selection set', function () {
instance.handleOnSelect('1234');
expect(instance.state.selection.has('1234')).toBeTruthy();
});
});
describe('when already selected', function () {
beforeEach(function () {
instance.setState({selection: new Set(['2314'])});
});
it('removes the selection from the set', function () {
instance.handleOnSelect('2314');
expect(instance.state.selection.has('1234')).toBeFalsy();
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment