fix: timer component, fixes #10849, closes #11002 (#11004)

This commit is contained in:
Jesse Yang
2020-09-23 10:53:24 -07:00
committed by GitHub
parent af1e8e8839
commit 7549dad12d
8 changed files with 99 additions and 77 deletions

View File

@@ -34,17 +34,15 @@ describe('Timer', () => {
wrapper = mount(<Timer {...mockedProps} />);
});
it('is a valid element', () => {
it('renders correctly', () => {
expect(React.isValidElement(<Timer {...mockedProps} />)).toBe(true);
expect(wrapper.find('span').hasClass('label-warning')).toBe(true);
});
it('useEffect starts timer after 30ms and sets state of clockStr', async () => {
it('should start timer and sets clockStr', async () => {
expect.assertions(2);
expect(wrapper.find('span').text()).toBe('');
await new Promise(r => setTimeout(r, 35));
expect(wrapper.find('span').text()).not.toBe('');
});
it('renders a span with the correct class', () => {
expect(wrapper.find('span').hasClass('label-warning')).toBe(true);
});
});