summaryrefslogtreecommitdiff
path: root/std/node/global_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/node/global_test.ts')
-rw-r--r--std/node/global_test.ts52
1 files changed, 52 insertions, 0 deletions
diff --git a/std/node/global_test.ts b/std/node/global_test.ts
new file mode 100644
index 000000000..9ce0b2132
--- /dev/null
+++ b/std/node/global_test.ts
@@ -0,0 +1,52 @@
+import "./global.ts";
+import { assert, assertStrictEquals } from "../testing/asserts.ts";
+import { Buffer as BufferModule } from "./buffer.ts";
+import processModule from "./process.ts";
+
+// Definitions for this are quite delicate
+// This ensures modifications to the global namespace don't break on TypeScript
+
+// TODO
+// Deno lint marks globals defined by this module as undefined
+// probably gonna change in the future
+
+Deno.test("global is correctly defined", () => {
+ // deno-lint-ignore no-undef
+ assertStrictEquals(global, globalThis);
+ // deno-lint-ignore no-undef
+ assertStrictEquals(global.Buffer, BufferModule);
+ // deno-lint-ignore no-undef
+ assertStrictEquals(global.process, process);
+});
+
+Deno.test("Buffer is correctly defined", () => {
+ //Check that Buffer is defined as a type as well
+ type x = Buffer;
+ // deno-lint-ignore no-undef
+ assertStrictEquals(Buffer, BufferModule);
+ // deno-lint-ignore no-undef
+ assert(Buffer.from);
+ // deno-lint-ignore no-undef
+ assertStrictEquals(global.Buffer, BufferModule);
+ // deno-lint-ignore no-undef
+ assert(global.Buffer.from);
+ assertStrictEquals(globalThis.Buffer, BufferModule);
+ assert(globalThis.Buffer.from);
+ assertStrictEquals(window.Buffer, BufferModule);
+ assert(window.Buffer.from);
+});
+
+Deno.test("process is correctly defined", () => {
+ // deno-lint-ignore no-undef
+ assertStrictEquals(process, processModule);
+ // deno-lint-ignore no-undef
+ assert(process.arch);
+ // deno-lint-ignore no-undef
+ assertStrictEquals(global.process, processModule);
+ // deno-lint-ignore no-undef
+ assert(global.process.arch);
+ assertStrictEquals(globalThis.process, processModule);
+ assert(globalThis.process.arch);
+ assertStrictEquals(window.process, processModule);
+ assert(window.process.arch);
+});