Skip to content
Myr

polyfills.js

This file

Path

__tests__/polyfills.js

54 lines · 1.2 KiB · JavaScript

Last changed by

chore: verify build during testMichel Weststratebefore adoptionef8990b

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–16why, one step back
11
12// Reset the globals to avoid unintended effects.13Symbol = SymbolConstructor14Object.assign = assign15Reflect.ownKeys = ownKeys16

chore: verify build during testMichel Weststratebefore adoptionef8990b

lines 17–31why, one step back
17if (!global.USES_BUILD)
18 describe("Symbol", () => {19 test("NOTHING", () => {20 const value = common.NOTHING21 expect(value).toBeTruthy()22 expect(typeof value).toBe("object")23 })24 test("DRAFTABLE", () => {25 const value = common.DRAFTABLE26 expect(typeof value).toBe("string")27 })28 test("DRAFT_STATE", () => {29 const value = common.DRAFT_STATE30 expect(typeof value).toBe("string")31 })

style: use tabsuse-tabsbefore adoptiona9c0fd0

line 32why, one step back
32 })

test: polyfillsaleclarsonbefore adoption551d877

line 33why, one step back
33

chore: verify build during testMichel Weststratebefore adoptionef8990b

lines 34–36why, one step back
34if (!global.USES_BUILD)
35 describe("Reflect.ownKeys", () => {36 const {ownKeys} = common

test: polyfillsaleclarsonbefore adoption551d877

line 37why, one step back
37

chore: verify build during testMichel Weststratebefore adoptionef8990b

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

test: polyfillsaleclarsonbefore adoption551d877

line 44why, one step back
44

chore: verify build during testMichel Weststratebefore adoptionef8990b

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

style: use tabsuse-tabsbefore adoptiona9c0fd0

line 50why, one step back
50 })

chore: verify build during testMichel Weststratebefore adoptionef8990b

lines 51–53why, one step back
51
52test("suppress jest warning", () => {53 expect(true).toBe(true)

test: polyfillsaleclarsonbefore adoption551d877

line 54why, one step back
54})