fix: 🐛 reload inaktivt i fejk (#10)

This commit is contained in:
Johan Öbrink 2021-02-23 11:55:30 +01:00 committed by GitHub
parent c32928369b
commit 9fa63e84fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 9 deletions

View File

@ -16,6 +16,8 @@ import store from './store'
const { default: init } = jest.requireActual('@skolplattformen/embedded-api')
const wait = (ms) => new Promise((res) => setTimeout(res, ms))
describe('hooks with fake data', () => {
let api
let storage
@ -176,16 +178,10 @@ describe('hooks with fake data', () => {
} = renderHook(() => useNotifications(child), { wrapper })
await waitForNextUpdate()
expect(result.current.status).toEqual('loaded')
result.current.reload()
await waitForNextUpdate()
result.current.reload()
result.current.reload()
await waitForNextUpdate()
result.current.reload()
await waitForNextUpdate()
await wait(30)
expect(result.current.status).toEqual('loaded')
})

View File

@ -49,7 +49,7 @@ const hook = <T>(
const dispatch = useDispatch()
const load = (force = false) => {
if (isLoggedIn && state.status !== 'loading' && (force || state.status === 'pending')) {
if (isLoggedIn && state.status !== 'loading' && ((force && !api.isFake) || state.status === 'pending')) {
const extra: ExtraActionProps<T> = {
key,
defaultValue,