mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 12:13:43 -05:00
Merge pull request #14966 from overleaf/jpa-avoid-fake-clock
[web] avoid faking the clock in frontend tests GitOrigin-RevId: 6fd5af54f1cbfa22901d24d47070fea097183394
This commit is contained in:
parent
6d31ff6400
commit
3383ec7908
1 changed files with 4 additions and 9 deletions
|
@ -12,7 +12,6 @@ import {
|
|||
cleanUpContext,
|
||||
} from '../../../helpers/render-with-context'
|
||||
import { stubMathJax, tearDownMathJaxStubs } from './stubs'
|
||||
import sinon from 'sinon'
|
||||
|
||||
describe('<ChatPane />', function () {
|
||||
const user = {
|
||||
|
@ -22,16 +21,11 @@ describe('<ChatPane />', function () {
|
|||
}
|
||||
|
||||
beforeEach(function () {
|
||||
this.clock = sinon.useFakeTimers({
|
||||
toFake: ['setTimeout', 'clearTimeout', 'setInterval', 'clearInterval'],
|
||||
})
|
||||
window.metaAttributesCache = new Map()
|
||||
window.metaAttributesCache.set('ol-user', user)
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
this.clock.runAll()
|
||||
this.clock.restore()
|
||||
fetchMock.reset()
|
||||
window.metaAttributesCache = new Map()
|
||||
})
|
||||
|
@ -98,12 +92,13 @@ describe('<ChatPane />', function () {
|
|||
|
||||
renderWithChatContext(<ChatPane />, { user })
|
||||
|
||||
this.clock.tick(600) // wait for spinner to be displayed
|
||||
// not displayed initially
|
||||
expect(screen.queryByText('Loading…')).to.not.exist
|
||||
|
||||
// eventually displayed
|
||||
await screen.findByText('Loading…')
|
||||
|
||||
this.clock.tick(1000) // wait for response to be received
|
||||
|
||||
// eventually removed when the fetch call returns
|
||||
await waitForElementToBeRemoved(() => screen.getByText('Loading…'))
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue