Tweaks to item test

This commit is contained in:
Tom Southall
2022-02-17 15:22:50 +00:00
parent 6954154ee0
commit 5ee40eab38

View File

@@ -21,25 +21,26 @@ const item = {
} }
} }
const index = 0
const component = renderer.create( const component = renderer.create(
<StateContextProvider styles={customStyles} text={'Chi'} items={[item]}> <StateContextProvider styles={customStyles} text={'Chi'} items={[item]}>
<Item <Item
index={0} index={index}
key={'item0'} key={`item${index}`}
item={item} item={item}
/> />
</StateContextProvider> </StateContextProvider>
) )
let tree = component.toJSON() let tree = component.toJSON()
describe('Item', () => { describe('Item', () => {
test('Component renders correctly', () => { test('Component renders correctly', () => {
expect(tree).toMatchSnapshot() expect(tree).toMatchSnapshot()
}) })
test('Link changes the class when hovered', () => { test('Link changes the class when hovered', () => {
// Manually trigger onMouseEnter callback and rerender // Manually trigger onMouseEnter and rerender
tree.props.onMouseEnter() tree.props.onMouseEnter()
tree = component.toJSON() tree = component.toJSON()