Skip to content

Commit

Permalink
test: fix failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
miracles1919 committed Apr 14, 2022
1 parent 2ae8d90 commit 376b89c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/switch/tests/switch.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react'
import { fireEvent, render, testA11y, waitFor } from 'testing'
import Switch from '..'
import { sleep } from '../../../utils/sleep'

const classPrefix = `adm-switch`

Expand Down Expand Up @@ -59,7 +60,7 @@ describe('Switch', () => {
return new Promise(resolve => {
setTimeout(() => {
resolve()
}, 1000)
}, 500)
})
}
return <Switch beforeChange={() => beforeChange()} data-testid='switch' />
Expand All @@ -69,6 +70,7 @@ describe('Switch', () => {
fireEvent.click(getByTestId('switch'))
expect(getByTestId('switch')).toHaveClass(`${classPrefix}-disabled`)

await sleep(500)
await waitFor(() => {
expect(getByTestId('switch')).toHaveClass(`${classPrefix}-checked`)
})
Expand Down

0 comments on commit 376b89c

Please sign in to comment.