Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewlipski committed Sep 30, 2024
1 parent bfedff3 commit 1350b9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 35 deletions.
39 changes: 7 additions & 32 deletions packages/core/src/api/blockManipulation/blockManipulation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ const schema = BlockNoteSchema.create({
let editor: BlockNoteEditor<typeof schema.blockSchema>;
const div = document.createElement("div");

function waitForEditor() {
// wait for create event on editor,
// this is necessary because otherwise UniqueId.create hasn't been called yet, and
// blocks would have "null" as their id
return new Promise<void>((resolve) => {
editor._tiptapEditor.on("create", () => {
resolve();
});
});
}

let singleBlock: PartialBlock<
typeof schema.blockSchema,
DefaultInlineContentSchema,
Expand Down Expand Up @@ -195,35 +184,27 @@ describe("Test strong typing", () => {
});

describe("Inserting Blocks with Different Placements", () => {
it("Insert before existing block", async () => {
await waitForEditor();

it("Insert before existing block", () => {
const output = insert("before");

expect(output).toMatchSnapshot();
});

it("Insert nested inside existing block", async () => {
await waitForEditor();

it("Insert nested inside existing block", () => {
const output = insert("nested");

expect(output).toMatchSnapshot();
});

it("Insert after existing block", async () => {
await waitForEditor();

it("Insert after existing block", () => {
const output = insert("after");

expect(output).toMatchSnapshot();
});
});

describe("Insert, Update, & Delete Blocks", () => {
it("Insert, update, & delete single block", async () => {
await waitForEditor();

it("Insert, update, & delete single block", () => {
const existingBlock = editor.document[0];
editor.insertBlocks([singleBlock], existingBlock);

Expand Down Expand Up @@ -263,9 +244,7 @@ describe("Insert, Update, & Delete Blocks", () => {
expect(editor.document).toMatchSnapshot();
});

it("Insert, update, & delete multiple blocks", async () => {
await waitForEditor();

it("Insert, update, & delete multiple blocks", () => {
const existingBlock = editor.document[0];
editor.insertBlocks(multipleBlocks, existingBlock);

Expand All @@ -286,9 +265,7 @@ describe("Insert, Update, & Delete Blocks", () => {
});

describe("Update Line Breaks", () => {
it("Update paragraph with line break", async () => {
await waitForEditor();

it("Update paragraph with line break", () => {
const existingBlock = editor.document[0];
editor.insertBlocks(blocksWithLineBreaks, existingBlock);

Expand All @@ -300,9 +277,7 @@ describe("Update Line Breaks", () => {

expect(editor.document).toMatchSnapshot();
});
it("Update custom block with line break", async () => {
await waitForEditor();

it("Update custom block with line break", () => {
const existingBlock = editor.document[0];
editor.insertBlocks(blocksWithLineBreaks, existingBlock);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import { getCurrentBlockContentType } from "../../../api/getCurrentBlockContentT

export const numberedListItemPropSchema = {
...defaultProps,
index: {
default: 0,
},
} satisfies PropSchema;

const NumberedListItemBlockContent = createStronglyTypedTiptapNode({
Expand Down

0 comments on commit 1350b9d

Please sign in to comment.