-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
packages/babel-plugin-polyfill-corejs3/test/check-builtin-definitions.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import corejs3Entries from "../core-js-compat/entries"; | ||
|
||
import { | ||
BuiltIns, | ||
StaticProperties, | ||
InstanceProperties, | ||
} from "../src/built-in-definitions.js"; | ||
|
||
const supportedCorejs3Modules = new Set(); | ||
|
||
const corejs3Modules = corejs3Entries["core-js"]; | ||
|
||
function addsupportedCorejs3Modules(descriptors) { | ||
for (const { global } of Object.values(descriptors)) { | ||
for (const dep of global) { | ||
supportedCorejs3Modules.add(dep); | ||
} | ||
} | ||
} | ||
addsupportedCorejs3Modules(BuiltIns); | ||
|
||
for (const properties of Object.values(StaticProperties)) { | ||
addsupportedCorejs3Modules(properties); | ||
} | ||
|
||
addsupportedCorejs3Modules(InstanceProperties); | ||
|
||
const allowList = new Set([]); | ||
|
||
describe("corejs3 builtin definitions", () => { | ||
it("should support most corejs3 features", () => { | ||
let todoListItem = 0; | ||
for (const name of corejs3Modules) { | ||
if (supportedCorejs3Modules.has(name)) continue; | ||
if (name.startsWith("es.")) { | ||
const esNextName = "esnext." + name.slice(3); | ||
if (supportedCorejs3Modules.has(esNextName)) { | ||
todoListItem++; | ||
console.error( | ||
`Please replace "${esNextName}" by "${name}" in | ||
packages/babel-plugin-polyfill-corejs3/src/built-in-definitions.js.`, | ||
); | ||
} else { | ||
if (!allowList.has(name)) { | ||
todoListItem++; | ||
console.error( | ||
`"${esNextName}" is not supported, please add it to | ||
packages/babel-plugin-polyfill-corejs3/src/built-in-definitions.js | ||
or the allowlist in packages/babel-plugin-polyfill-corejs3/test/check-builtin-definitions.test.js`, | ||
); | ||
} | ||
} | ||
} | ||
} | ||
expect(todoListItem).toBe(0); | ||
}); | ||
}); |