mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(ext/node): use primordials in ext/node/polyfills/testing.ts
(#24310)
Towards #24236
This commit is contained in:
parent
973d186e8f
commit
1c7ae83ca1
1 changed files with 18 additions and 14 deletions
|
@ -1,8 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||
// deno-lint-ignore-file prefer-primordials
|
||||
|
||||
import { primordials } from "ext:core/mod.js";
|
||||
const { PromisePrototypeThen } = primordials;
|
||||
import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts";
|
||||
|
||||
export function run() {
|
||||
|
@ -54,17 +53,20 @@ class NodeTestContext {
|
|||
|
||||
test(name, options, fn) {
|
||||
const prepared = prepareOptions(name, options, fn, {});
|
||||
return this.#denoContext.step({
|
||||
name: prepared.name,
|
||||
fn: async (denoTestContext) => {
|
||||
const newNodeTextContext = new NodeTestContext(denoTestContext);
|
||||
await prepared.fn(newNodeTextContext);
|
||||
},
|
||||
ignore: prepared.options.todo || prepared.options.skip,
|
||||
sanitizeExit: false,
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
}).then(() => undefined);
|
||||
return PromisePrototypeThen(
|
||||
this.#denoContext.step({
|
||||
name: prepared.name,
|
||||
fn: async (denoTestContext) => {
|
||||
const newNodeTextContext = new NodeTestContext(denoTestContext);
|
||||
await prepared.fn(newNodeTextContext);
|
||||
},
|
||||
ignore: prepared.options.todo || prepared.options.skip,
|
||||
sanitizeExit: false,
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
}),
|
||||
() => undefined,
|
||||
);
|
||||
}
|
||||
|
||||
before(_fn, _options) {
|
||||
|
@ -127,6 +129,8 @@ function wrapTestFn(fn, resolve) {
|
|||
function prepareDenoTest(name, options, fn, overrides) {
|
||||
const prepared = prepareOptions(name, options, fn, overrides);
|
||||
|
||||
// TODO(iuioiua): Update once there's a primordial for `Promise.withResolvers()`.
|
||||
// deno-lint-ignore prefer-primordials
|
||||
const { promise, resolve } = Promise.withResolvers();
|
||||
|
||||
const denoTestOptions = {
|
||||
|
|
Loading…
Reference in a new issue