-
Notifications
You must be signed in to change notification settings - Fork 154
BigClickableButton component test #350
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* eslint-disable flowtype/require-valid-file-annotation */ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import BigClickableButton from './BigClickableButton'; | ||
// Use Lolex to mock setTimeout - later use Jest mock once PR https://github.com/facebook/jest/pull/5171 landed | ||
import lolex from 'lolex'; | ||
|
||
describe('BigClickableButton component', () => { | ||
let wrapper; | ||
let button; | ||
lolex.install(); // mock setTimeout | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also not familiar with Lolex but I think it's OK here to not call But if we would use it to test a spring at different tick positions we should add install to I haven't tested a spring animation yet but |
||
|
||
beforeEach(() => { | ||
wrapper = mount(<BigClickableButton />); | ||
button = wrapper.find('button'); | ||
jest.clearAllTimers(); | ||
button.simulate('mouseDown'); | ||
}); | ||
|
||
it('should render pressed', () => { | ||
expect(wrapper.state('isActive')).toBeTruthy(); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render released', () => { | ||
button.simulate('mouseUp'); | ||
expect(wrapper.state('isActive')).toBeFalsy(); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a
// TODO
so we don't forget