Skip to content

Commit

Permalink
Cleanup overwriting globals tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Feb 22, 2019
1 parent d577412 commit 15acb86
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions test/misc-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -270,7 +271,7 @@ describe("miscellaneous tests", () => {
writable: true
})

Reflect.defineProperty(global, "Reflect", {
defineProperty(global, "Reflect", {
configurable: true,
value: {
get() {
Expand All @@ -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"])
})
Expand Down

0 comments on commit 15acb86

Please sign in to comment.