From fb13e7ae5e46b20d1cd65107658cb6361997500c Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 12 Feb 2022 15:27:28 +0800 Subject: [PATCH] test: add more test --- test/core/test/execution-order.test.ts | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/core/test/execution-order.test.ts diff --git a/test/core/test/execution-order.test.ts b/test/core/test/execution-order.test.ts new file mode 100644 index 000000000000..822d58b0227f --- /dev/null +++ b/test/core/test/execution-order.test.ts @@ -0,0 +1,49 @@ +import { describe, expect, it } from 'vitest' + +let v = 0 + +function bumpSync() { + v += 1 +} + +function bump() { + return new Promise((resolve) => { + setTimeout(() => { + v += 1 + resolve() + }, 1) + }) +} + +it('one', () => { + bumpSync() + expect(v).toBe(1) +}) + +it('two', async() => { + expect(v).toBe(1) + await bump() + expect(v).toBe(2) +}) + +describe('suite', () => { + it('three', () => { + bumpSync() + expect(v).toBe(3) + }) + + it('four', async() => { + expect(v).toBe(3) + await bump() + expect(v).toBe(4) + }) + + it('four', () => { + expect(v).toBe(4) + }) + + it('five', () => { + bumpSync() + expect(v).toBe(5) + }) +})