summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/testdata/npm/compare_globals/main.out3
-rw-r--r--cli/tests/testdata/npm/compare_globals/main.ts13
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.d.ts2
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.js4
4 files changed, 22 insertions, 0 deletions
diff --git a/cli/tests/testdata/npm/compare_globals/main.out b/cli/tests/testdata/npm/compare_globals/main.out
index 8b3b62bc1..e60a39ba6 100644
--- a/cli/tests/testdata/npm/compare_globals/main.out
+++ b/cli/tests/testdata/npm/compare_globals/main.out
@@ -5,3 +5,6 @@ Download http://localhost:4545/npm/registry/@types/node/node-18.8.2.tgz
Check file:///[WILDCARD]/npm/compare_globals/main.ts
true
[]
+5
+undefined
+undefined
diff --git a/cli/tests/testdata/npm/compare_globals/main.ts b/cli/tests/testdata/npm/compare_globals/main.ts
index 5710d0bd5..0468404a8 100644
--- a/cli/tests/testdata/npm/compare_globals/main.ts
+++ b/cli/tests/testdata/npm/compare_globals/main.ts
@@ -12,3 +12,16 @@ type _TestHasNodeJsGlobal = NodeJS.Architecture;
const controller = new AbortController();
controller.abort("reason"); // in the NodeJS declaration it doesn't have a reason
+
+// Super edge case where some Node code deletes a global where the
+// Node code has its own global and the Deno code has the same global,
+// but it's different. Basically if some Node code deletes
+// one of these globals then we don't want it to suddenly inherit
+// the Deno global.
+globals.withNodeGlobalThis((nodeGlobalThis: any) => {
+ (globalThis as any).setTimeout = 5;
+ console.log(setTimeout);
+ delete nodeGlobalThis["setTimeout"];
+ console.log(nodeGlobalThis["setTimeout"]); // should be undefined
+ console.log(globalThis["setTimeout"]); // should be undefined
+});
diff --git a/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.d.ts b/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.d.ts
index ee03712dd..3f3eeb92a 100644
--- a/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.d.ts
+++ b/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.d.ts
@@ -11,3 +11,5 @@ type AssertTrue<T extends true> = never;
type _TestHasProcessGlobal = AssertTrue<
typeof globalThis extends { process: any } ? true : false
>;
+
+export function withNodeGlobalThis(action: (global: typeof globalThis) => void): void;
diff --git a/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.js b/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.js
index 50d2d3d2a..daac83c66 100644
--- a/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.js
+++ b/cli/tests/testdata/npm/registry/@denotest/globals/1.0.0/index.js
@@ -1,3 +1,7 @@
exports.globalThis = globalThis;
exports.global = global;
exports.process = process;
+
+exports.withNodeGlobalThis = function (action) {
+ action(globalThis);
+};