Debian Codegraph @

packages/babel-standalone/test/preset-stage-1.test.js

raw symbols SCIP
1 import { createRequire } from "module";
2 const require = createRequire(import.meta.url);
3
4 describe("stage-1 preset", () => {
5 let Babel;
6 beforeAll(() => {
7 Babel = require("../babel.js");
8 });
9
10 it("should parser decimal literal", () => {
11 const output = Babel.transform("0.3m", {
12 presets: [["stage-1", { decoratorsLegacy: true }]],
13 }).code;
14 expect(output).toBe("0.3m;");
15 });
16
17 it("should support hack pipeline", () => {
18 const output = Babel.transform("x |> %", {
19 presets: [
20 [
21 "stage-1",
22 {
23 pipelineProposal: "hack",
24 decoratorsLegacy: true,
25 },
26 ],
27 ],
28 }).code;
29 expect(output).toMatchInlineSnapshot(`"x;"`);
30 });
31
32 it("should support hack pipeline with `#` topic token", () => {
33 const output = Babel.transform("x |> #", {
34 presets: [
35 [
36 "stage-1",
37 {
38 pipelineProposal: "hack",
39 pipelineTopicToken: "#",
40 recordAndTupleSyntax: "bar",
41 decoratorsLegacy: true,
42 },
43 ],
44 ],
45 }).code;
46 expect(output).toMatchInlineSnapshot(`"x;"`);
47 });
48 it("should support decorators versioned 2021-12", () => {
49 const output = Babel.transform("@dec class C {}", {
50 plugins: [["external-helpers", { helperVersion: "7.100.0" }]],
51 presets: [["stage-1", { decoratorsVersion: "2021-12" }]],
52 }).code;
53 expect(output).toMatch("babelHelpers.applyDecs");
54 });
55 it("should support private destructuring", () => {
56 const output = Babel.transform("class C { #x; m({ #x: x}) {} }", {
57 plugins: [["external-helpers", { helperVersion: "7.100.0" }]],
58 presets: [
59 [
60 "stage-1",
61 {
62 decoratorsVersion: "2021-12",
63 },
64 ],
65 ],
66 }).code;
67 expect(output).not.toContain("#x:");
68 });
69 it("should support regexp v flag", () => {
70 const output = Babel.transform("/[[a-p]&&[d-z]]/v", {
71 presets: [["stage-1", { decoratorsVersion: "2021-12" }]],
72 }).code;
73 expect(output).toMatchInlineSnapshot(`"/[d-p]/u;"`);
74 });
75 it("should support record and tuple", () => {
76 const output = Babel.transform("#[#{}]", {
77 presets: [["stage-1", { decoratorsVersion: "2021-12" }]],
78 }).code;
79 expect(output).toMatchInlineSnapshot(`"Tuple(Record({}));"`);
80 });
81 });