Skip to content

Commit

Permalink
test: add multiple onTestFinished tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Apr 23, 2024
1 parent 1ef5e36 commit a22f2cc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/core/test/on-finished.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, it, onTestFinished } from 'vitest'

const collected: any[] = []
const multiple: any[] = []

it('on-finished regular', () => {
collected.push(1)
Expand Down Expand Up @@ -38,6 +39,23 @@ it.fails('failed finish context', (t) => {
collected.push(null)
})

it('multiple on-finished', () => {
onTestFinished(() => {
multiple.push(1)
})
onTestFinished(() => {
multiple.push(2)
})
onTestFinished(async () => {
await new Promise(r => setTimeout(r, 100))
multiple.push(3)
})
onTestFinished(() => {
multiple.push(4)
})
})

it('after', () => {
expect(collected).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
expect(multiple).toEqual([4, 3, 2, 1])
})

0 comments on commit a22f2cc

Please sign in to comment.