-
-
Save trevlar/db60cd4f7d4a0f087e129f20d2b941c4 to your computer and use it in GitHub Desktop.
List Wrapper Spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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