Skip to content
Myr

polyfills.js

This file

Path

__tests__/polyfills.js

48 lines · 1.1 KiB · JavaScript

Last changed by

fix: Map and Set instantions won't work on certain environments, fixes #502Michel Weststratebefore adoption9f4711a

History of this file

Take it

test: polyfillsaleclarsonbefore adoption551d877

lines 1–9why, one step back
1const {assign} = Object
2const {ownKeys} = Reflect3const SymbolConstructor = Symbol45Symbol = undefined6Object.assign = undefined7Reflect.ownKeys = undefined89jest.resetModules()

fix: Map and Set instantions won't work on certain environments, fixes #502Michel Weststratebefore adoption9f4711a

line 10why, one step back
10const common = require("../src/internal")

test: polyfillsaleclarsonbefore adoption551d877

lines 11–17why, one step back
11
12// Reset the globals to avoid unintended effects.13Symbol = SymbolConstructor14Object.assign = assign15Reflect.ownKeys = ownKeys1617describe("Symbol", () => {

style: use tabsuse-tabsbefore adoptiona9c0fd0

lines 18–30why, one step back
18 test("NOTHING", () => {
19 const value = common.NOTHING20 expect(value).toBeTruthy()21 expect(typeof value).toBe("object")22 })23 test("DRAFTABLE", () => {24 const value = common.DRAFTABLE25 expect(typeof value).toBe("string")26 })27 test("DRAFT_STATE", () => {28 const value = common.DRAFT_STATE29 expect(typeof value).toBe("string")30 })

test: polyfillsaleclarsonbefore adoption551d877

lines 31–33why, one step back
31})
3233describe("Reflect.ownKeys", () => {

style: use tabsuse-tabsbefore adoptiona9c0fd0

line 34why, one step back
34 const {ownKeys} = common

test: polyfillsaleclarsonbefore adoption551d877

line 35why, one step back
35

style: use tabsuse-tabsbefore adoptiona9c0fd0

lines 36–41why, one step back
36 // Symbol keys are always last.
37 it("includes symbol keys", () => {38 const s = SymbolConstructor()39 const obj = {[s]: 1, b: 1}40 expect(ownKeys(obj)).toEqual(["b", s])41 })

test: polyfillsaleclarsonbefore adoption551d877

line 42why, one step back
42

style: use tabsuse-tabsbefore adoptiona9c0fd0

lines 43–47why, one step back
43 it("includes non-enumerable keys", () => {
44 const obj = {a: 1}45 Object.defineProperty(obj, "b", {value: 1})46 expect(ownKeys(obj)).toEqual(["a", "b"])47 })

test: polyfillsaleclarsonbefore adoption551d877

line 48why, one step back
48})