-
Notifications
You must be signed in to change notification settings - Fork 154
Conversation
Codecov Report
@@ Coverage Diff @@
## master #350 +/- ##
==========================================
+ Coverage 24.91% 25.64% +0.73%
==========================================
Files 152 152
Lines 3625 3618 -7
Branches 388 388
==========================================
+ Hits 903 928 +25
+ Misses 2450 2420 -30
+ Partials 272 270 -2
|
describe('BigClickableButton component', () => { | ||
let wrapper; | ||
let button; | ||
lolex.install(); // mock setTimeout |
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.
Do we need to uninstall
after this is done? Not familiar with lolex but they are uninstalling in each example in their docs.
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.
I'm also not familiar with Lolex but I think it's OK here to not call uninstall
as we're only needing a static value for Date.now()
.
But if we would use it to test a spring at different tick positions we should add install to beforeEach
and uninstall
in afterEach
- so we're having a fresh timer mock at each test.
I haven't tested a spring animation yet but clock.next()
seems the way to test the next fired timeout event where clock = lolex.install()
or clock.tick(100)
to increment the timer by 100ms.
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.
This LGTM! Just add the todo comment then let's get it merged.
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 |
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
Related Issue:
#309
Summary:
Two snapshot tests for button states.
Added lolex devDependency to mock
setTimeout
used by React-Spring. Otherwise every test run was creating a different snapshot because_idleStart
changed.We can remove
Lolex
later as it will be added to Jest but that's not ready yet. See link to PR in code comment.