Skip to content
Myr

polyfills.js

This file

Path

__tests__/polyfills.js

86 lines · 1.9 KiB · JavaScript

Last changed by

fix: `getOwnPropertyDescriptors` is not available in Internet Explorer and Hermes. Fixes #626Michel Weststratebefore adoptionc7a47e2

History of this file

Take it

The walk stopped after 200 commits: lines older than f9cd736 point at it.

fix: `getOwnPropertyDescriptors` is not available in Internet Explorer and Hermes. Fixes #626Michel Weststratebefore adoptionc7a47e2

line 1why, one step back
1const {assign, getOwnPropertyDescriptors} = Object

test: improve "nested producer" testsaleclarsonbefore adoptionf9cd736

lines 2–4why, one step back
2const {ownKeys} = Reflect
3const SymbolConstructor = Symbol4

fix: `getOwnPropertyDescriptors` is not available in Internet Explorer and Hermes. Fixes #626Michel Weststratebefore adoptionc7a47e2

lines 5–6why, one step back
5const testSymbol = Symbol("test-symbol")
6

test: improve "nested producer" testsaleclarsonbefore adoptionf9cd736

lines 7–9why, one step back
7Symbol = undefined
8Object.assign = undefined9Reflect.ownKeys = undefined

fix: `getOwnPropertyDescriptors` is not available in Internet Explorer and Hermes. Fixes #626Michel Weststratebefore adoptionc7a47e2

line 10why, one step back
10Object.getOwnPropertyDescriptors = undefined

test: improve "nested producer" testsaleclarsonbefore adoptionf9cd736

lines 11–12why, one step back
11
12jest.resetModules()

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

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

test: improve "nested producer" testsaleclarsonbefore adoptionf9cd736

lines 14–18why, one step back
14
15// Reset the globals to avoid unintended effects.16Symbol = SymbolConstructor17Object.assign = assign18Reflect.ownKeys = ownKeys

fix: `getOwnPropertyDescriptors` is not available in Internet Explorer and Hermes. Fixes #626Michel Weststratebefore adoptionc7a47e2

line 19why, one step back
19Object.getOwnPropertyDescriptors = getOwnPropertyDescriptors

test: improve "nested producer" testsaleclarsonbefore adoptionf9cd736

line 20why, one step back
20

chore: verify build during testMichel Weststratebefore adoptionef8990b

lines 21–35why, one step back
21if (!global.USES_BUILD)
22 describe("Symbol", () => {23 test("NOTHING", () => {24 const value = common.NOTHING25 expect(value).toBeTruthy()26 expect(typeof value).toBe("object")27 })28 test("DRAFTABLE", () => {29 const value = common.DRAFTABLE30 expect(typeof value).toBe("string")31 })32 test("DRAFT_STATE", () => {33 const value = common.DRAFT_STATE34 expect(typeof value).toBe("string")35 })

style: use tabsuse-tabsbefore adoptiona9c0fd0

line 36why, one step back
36 })

test: improve "nested producer" testsaleclarsonbefore adoptionf9cd736

line 37why, one step back
37

chore: verify build during testMichel Weststratebefore adoptionef8990b

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

test: improve "nested producer" testsaleclarsonbefore adoptionf9cd736

line 41why, one step back
41

chore: verify build during testMichel Weststratebefore adoptionef8990b

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

test: improve "nested producer" testsaleclarsonbefore adoptionf9cd736

line 48why, one step back
48

chore: verify build during testMichel Weststratebefore adoptionef8990b

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

fix: `getOwnPropertyDescriptors` is not available in Internet Explorer and Hermes. Fixes #626Michel Weststratebefore adoptionc7a47e2

lines 53–80why, one step back
53 })
54 })5556if (!global.USES_BUILD)57 describe("Object.getOwnPropertyDescriptors", () => {58 const {getOwnPropertyDescriptors} = common5960 // Symbol keys are always last.61 it("gets symbolic and nonsymbolic properties", () => {62 expect(63 Object.getOwnPropertyDescriptors({64 x: 1,65 [testSymbol]: 266 })67 ).toEqual({68 x: {69 value: 1,70 enumerable: true,71 configurable: true,72 writable: true73 },74 [testSymbol]: {75 value: 2,76 enumerable: true,77 configurable: true,78 writable: true79 }80 })

chore: verify build during testMichel Weststratebefore adoptionef8990b

line 81why, one step back
81 })

style: use tabsuse-tabsbefore adoptiona9c0fd0

line 82why, one step back
82 })

chore: verify build during testMichel Weststratebefore adoptionef8990b

lines 83–85why, one step back
83
84test("suppress jest warning", () => {85 expect(true).toBe(true)

test: improve "nested producer" testsaleclarsonbefore adoptionf9cd736

line 86why, one step back
86})