mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-12 21:00:02 +08:00

Some checks are pending
build / build (20) (push) Waiting to run
build / test (20, map[name:Demos/Commands spec:./demos/src/Commands/**/*.spec.{js,ts}]) (push) Blocked by required conditions
build / test (20, map[name:Demos/Examples spec:./demos/src/Examples/**/*.spec.{js,ts}]) (push) Blocked by required conditions
build / test (20, map[name:Demos/Experiments spec:./demos/src/Experiments/**/*.spec.{js,ts}]) (push) Blocked by required conditions
build / test (20, map[name:Demos/Extensions spec:./demos/src/Extensions/**/*.spec.{js,ts}]) (push) Blocked by required conditions
build / test (20, map[name:Demos/GuideContent spec:./demos/src/GuideContent/**/*.spec.{js,ts}]) (push) Blocked by required conditions
build / test (20, map[name:Demos/GuideGettingStarted spec:./demos/src/GuideGettingStarted/**/*.spec.{js,ts}]) (push) Blocked by required conditions
build / test (20, map[name:Demos/Marks spec:./demos/src/Marks/**/*.spec.{js,ts}]) (push) Blocked by required conditions
build / test (20, map[name:Demos/Nodes spec:./demos/src/Nodes/**/*.spec.{js,ts}]) (push) Blocked by required conditions
build / test (20, map[name:Integration spec:./tests/cypress/integration/**/*.spec.{js,ts}]) (push) Blocked by required conditions
build / release (20) (push) Blocked by required conditions
Publish / Release (20) (push) Waiting to run
166 lines
5.0 KiB
TypeScript
166 lines
5.0 KiB
TypeScript
/* eslint-disable semi */
|
|
import jscodeshift, { type API } from "jscodeshift";
|
|
import assert from "node:assert";
|
|
import { readFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { describe, it } from "vitest";
|
|
|
|
import transform from "../src/index.js";
|
|
|
|
const buildApi = (parser: string | undefined): API => ({
|
|
j: parser ? jscodeshift.withParser(parser) : jscodeshift,
|
|
jscodeshift: parser ? jscodeshift.withParser(parser) : jscodeshift,
|
|
stats: () => {
|
|
console.error("The stats function was called, which is not supported on purpose");
|
|
},
|
|
report: () => {
|
|
console.error("The report function was called, which is not supported on purpose");
|
|
},
|
|
});
|
|
|
|
describe("tiptap/2/consolidate-extensions", () => {
|
|
it("test #1", async () => {
|
|
const INPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture1.input"), "utf-8");
|
|
const OUTPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture1.output"), "utf-8");
|
|
|
|
const actualOutput = transform(
|
|
{
|
|
path: "index.js",
|
|
source: INPUT,
|
|
},
|
|
buildApi("tsx"), // @ts-expect-error
|
|
{},
|
|
);
|
|
|
|
assert.deepEqual(actualOutput?.replace(/W/gm, ""), OUTPUT.replace(/W/gm, ""));
|
|
});
|
|
|
|
it("test #2", async () => {
|
|
const INPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture2.input"), "utf-8");
|
|
const OUTPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture2.output"), "utf-8");
|
|
|
|
const actualOutput = transform(
|
|
{
|
|
path: "index.js",
|
|
source: INPUT,
|
|
},
|
|
buildApi("tsx"), // @ts-expect-error
|
|
{},
|
|
);
|
|
|
|
assert.deepEqual(actualOutput?.replace(/W/gm, ""), OUTPUT.replace(/W/gm, ""));
|
|
});
|
|
|
|
it("test #3", async () => {
|
|
const INPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture3.input"), "utf-8");
|
|
const OUTPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture3.output"), "utf-8");
|
|
|
|
const actualOutput = transform(
|
|
{
|
|
path: "index.js",
|
|
source: INPUT,
|
|
},
|
|
buildApi("tsx"), // @ts-expect-error
|
|
{},
|
|
);
|
|
|
|
assert.deepEqual(actualOutput?.replace(/W/gm, ""), OUTPUT.replace(/W/gm, ""));
|
|
});
|
|
|
|
it("test #4", async () => {
|
|
const INPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture4.input"), "utf-8");
|
|
const OUTPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture4.output"), "utf-8");
|
|
|
|
const actualOutput = transform(
|
|
{
|
|
path: "index.js",
|
|
source: INPUT,
|
|
},
|
|
buildApi("tsx"), // @ts-expect-error
|
|
{},
|
|
);
|
|
|
|
assert.deepEqual(actualOutput?.replace(/W/gm, ""), OUTPUT.replace(/W/gm, ""));
|
|
});
|
|
|
|
it("test #5", async () => {
|
|
const INPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture5.input"), "utf-8");
|
|
const OUTPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture5.output"), "utf-8");
|
|
|
|
const actualOutput = transform(
|
|
{
|
|
path: "index.js",
|
|
source: INPUT,
|
|
},
|
|
buildApi("tsx"),
|
|
// @ts-expect-error
|
|
{},
|
|
);
|
|
|
|
assert.deepEqual(actualOutput?.replace(/W/gm, ""), OUTPUT.replace(/W/gm, ""));
|
|
});
|
|
|
|
it("test #6", async () => {
|
|
const INPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture6.input"), "utf-8");
|
|
const OUTPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture6.output"), "utf-8");
|
|
|
|
const actualOutput = transform(
|
|
{
|
|
path: "index.js",
|
|
source: INPUT,
|
|
},
|
|
buildApi("tsx"), // @ts-expect-error
|
|
{},
|
|
);
|
|
|
|
assert.deepEqual(actualOutput?.replace(/W/gm, ""), OUTPUT.replace(/W/gm, ""));
|
|
});
|
|
|
|
it("test #7", async () => {
|
|
const INPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture7.input"), "utf-8");
|
|
const OUTPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture7.output"), "utf-8");
|
|
|
|
const actualOutput = transform(
|
|
{
|
|
path: "index.js",
|
|
source: INPUT,
|
|
},
|
|
buildApi("tsx"), // @ts-expect-error
|
|
{},
|
|
);
|
|
|
|
assert.deepEqual(actualOutput?.replace(/W/gm, ""), OUTPUT.replace(/W/gm, ""));
|
|
});
|
|
|
|
it("test #8", async () => {
|
|
const INPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture8.input"), "utf-8");
|
|
const OUTPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture8.output"), "utf-8");
|
|
|
|
const actualOutput = transform(
|
|
{
|
|
path: "index.js",
|
|
source: INPUT,
|
|
},
|
|
buildApi("tsx"), // @ts-expect-error
|
|
{},
|
|
);
|
|
|
|
assert.deepEqual(actualOutput?.replace(/W/gm, ""), OUTPUT.replace(/W/gm, ""));
|
|
});
|
|
it("test #9", async () => {
|
|
const INPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture9.input"), "utf-8");
|
|
const OUTPUT = await readFile(join(__dirname, "..", "__testfixtures__/fixture9.output"), "utf-8");
|
|
|
|
const actualOutput = transform(
|
|
{
|
|
path: "index.js",
|
|
source: INPUT,
|
|
},
|
|
buildApi("tsx"), // @ts-expect-error
|
|
{},
|
|
);
|
|
|
|
assert.deepEqual(actualOutput?.replace(/W/gm, ""), OUTPUT.replace(/W/gm, ""));
|
|
});
|
|
});
|