diff options
author | Yongwook Choi <hyperflow@kakao.com> | 2022-04-06 23:51:38 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-06 16:51:38 +0200 |
commit | 0df18542499d1220f1182496d3b7028eef243eb0 (patch) | |
tree | dbfb2fb6490371c45eadd9eabe0a8e81ea304fa1 /cli/tests/unit/testing_test.ts | |
parent | e33329b47ea1586bd1fbc686cae3048a080039ca (diff) |
feat(test): Add "name", "origin" and "parent" to "Deno.TestContext" (#14007)
This commit adds following fields to "Deno.TestContext" interface:
- name
- origin
- parent
These are prerequisites for supporting snapshot functionality in
"std/testing".
Diffstat (limited to 'cli/tests/unit/testing_test.ts')
-rw-r--r-- | cli/tests/unit/testing_test.ts | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/cli/tests/unit/testing_test.ts b/cli/tests/unit/testing_test.ts index 87b862a7d..90575aeb2 100644 --- a/cli/tests/unit/testing_test.ts +++ b/cli/tests/unit/testing_test.ts @@ -1,5 +1,5 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -import { assertRejects, assertThrows } from "./test_util.ts"; +import { assertEquals, assertRejects, assertThrows } from "./test_util.ts"; Deno.test(function testWrongOverloads() { assertThrows( @@ -117,3 +117,33 @@ Deno.test(async function invalidStepArguments(t) { "Expected a test definition or name and function.", ); }); + +Deno.test(async function nameOnTextContext(t1) { + await assertEquals(t1.name, "nameOnTextContext"); + await t1.step("step", async (t2) => { + await assertEquals(t2.name, "step"); + await t2.step("nested step", async (t3) => { + await assertEquals(t3.name, "nested step"); + }); + }); +}); + +Deno.test(async function originOnTextContext(t1) { + await assertEquals(t1.origin, Deno.mainModule); + await t1.step("step", async (t2) => { + await assertEquals(t2.origin, Deno.mainModule); + await t2.step("nested step", async (t3) => { + await assertEquals(t3.origin, Deno.mainModule); + }); + }); +}); + +Deno.test(async function parentOnTextContext(t1) { + await assertEquals(t1.parent, undefined); + await t1.step("step", async (t2) => { + await assertEquals(t1, t2.parent); + await t2.step("nested step", async (t3) => { + await assertEquals(t2, t3.parent); + }); + }); +}); |