From 15acb86ee8a36b38159139891b4ad361e92b34f4 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 22 Feb 2019 21:20:52 +0000 Subject: [PATCH] Cleanup overwriting globals tests. --- test/misc-tests.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/misc-tests.js b/test/misc-tests.js index 8139d8482..1b244e018 100644 --- a/test/misc-tests.js +++ b/test/misc-tests.js @@ -257,10 +257,11 @@ describe("miscellaneous tests", () => { }) it("should support overwriting globals", () => { + const { defineProperty } = Reflect const consoleDescriptor = Reflect.getOwnPropertyDescriptor(global, "console") const reflectDescriptor = Reflect.getOwnPropertyDescriptor(global, "Reflect") - Reflect.defineProperty(global, "console", { + defineProperty(global, "console", { configurable: true, value: { dir() { @@ -270,7 +271,7 @@ describe("miscellaneous tests", () => { writable: true }) - Reflect.defineProperty(global, "Reflect", { + defineProperty(global, "Reflect", { configurable: true, value: { get() { @@ -280,15 +281,13 @@ describe("miscellaneous tests", () => { writable: true }) - const object = {} - const actual = [ - console.dir(object), - Reflect.get(object, "a") + console.dir({}), + Reflect.get({}, "a") ] - Object.defineProperty(global, "console", consoleDescriptor) - Object.defineProperty(global, "Reflect", reflectDescriptor) + defineProperty(global, "console", consoleDescriptor) + defineProperty(global, "Reflect", reflectDescriptor) assert.deepStrictEqual(actual, ["mock", "mock"]) })