From e8fab81f46941f77238f6e37d92d4305a4629faa Mon Sep 17 00:00:00 2001 From: yousefed Date: Sun, 5 Mar 2023 14:27:25 +0100 Subject: [PATCH] move unittests --- .../blockManipulation.test.ts.snap | 0 .../blockManipulation.test.ts | 13 +-- .../formatConversions.test.ts.snap | 0 .../formatConversions.test.ts | 103 +++++++++--------- .../nodeConversions.test.ts.snap | 0 .../nodeConversions}/nodeConversions.test.ts | 12 +- 6 files changed, 60 insertions(+), 68 deletions(-) rename packages/core/{test => src/api/blockManipulation}/__snapshots__/blockManipulation.test.ts.snap (100%) rename packages/core/{test => src/api/blockManipulation}/blockManipulation.test.ts (94%) rename packages/core/{test => src/api/formatConversions}/__snapshots__/formatConversions.test.ts.snap (100%) rename packages/core/{test => src/api/formatConversions}/formatConversions.test.ts (90%) rename packages/core/{test => src/api/nodeConversions}/__snapshots__/nodeConversions.test.ts.snap (100%) rename packages/core/{test => src/api/nodeConversions}/nodeConversions.test.ts (94%) diff --git a/packages/core/test/__snapshots__/blockManipulation.test.ts.snap b/packages/core/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap similarity index 100% rename from packages/core/test/__snapshots__/blockManipulation.test.ts.snap rename to packages/core/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap diff --git a/packages/core/test/blockManipulation.test.ts b/packages/core/src/api/blockManipulation/blockManipulation.test.ts similarity index 94% rename from packages/core/test/blockManipulation.test.ts rename to packages/core/src/api/blockManipulation/blockManipulation.test.ts index f13f2f1c13..22b57e58c3 100644 --- a/packages/core/test/blockManipulation.test.ts +++ b/packages/core/src/api/blockManipulation/blockManipulation.test.ts @@ -1,8 +1,8 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; -import { Block, BlockNoteEditor, PartialBlock } from "../src"; +import { Block, BlockNoteEditor, PartialBlock } from "../.."; let editor: BlockNoteEditor; -let ready = false; + function waitForEditor() { // wait for create event on editor, // this is necessary because otherwise UniqueId.create hasn't been called yet, and @@ -23,11 +23,7 @@ let insert: (placement: "before" | "nested" | "after") => Block[]; beforeEach(() => { (window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS = {}; - editor = new BlockNoteEditor({ - onCreate: () => { - ready = true; - }, - }); + editor = new BlockNoteEditor(); singleBlock = { type: "paragraph", @@ -78,9 +74,8 @@ beforeEach(() => { }); afterEach(() => { - ready = false; editor._tiptapEditor.destroy(); - editor = undefined; + editor = undefined as any; delete (window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS; }); diff --git a/packages/core/test/__snapshots__/formatConversions.test.ts.snap b/packages/core/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap similarity index 100% rename from packages/core/test/__snapshots__/formatConversions.test.ts.snap rename to packages/core/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap diff --git a/packages/core/test/formatConversions.test.ts b/packages/core/src/api/formatConversions/formatConversions.test.ts similarity index 90% rename from packages/core/test/formatConversions.test.ts rename to packages/core/src/api/formatConversions/formatConversions.test.ts index 24d2ee1cb8..f93ed6cd08 100644 --- a/packages/core/test/formatConversions.test.ts +++ b/packages/core/src/api/formatConversions/formatConversions.test.ts @@ -1,7 +1,6 @@ -import {Block} from "@blocknote/core"; -import {afterEach, beforeEach, describe, expect, it} from "vitest"; -import { BlockNoteEditor } from "../src"; -import UniqueID from "../src/extensions/UniqueID/UniqueID"; +import { afterEach, beforeEach, describe, expect, it } from "vitest"; +import { Block, BlockNoteEditor } from "../.."; +import UniqueID from "../../extensions/UniqueID/UniqueID"; let editor: BlockNoteEditor; @@ -173,15 +172,15 @@ Paragraph ], }, ]; -// nestedHTML = `

Heading

Paragraph

`; -// nestedMarkdown = `# Heading -// -// Paragraph -// -// * Bullet List Item -// -// 1. Numbered List Item -// `; + // nestedHTML = `

Heading

Paragraph

`; + // nestedMarkdown = `# Heading + // + // Paragraph + // + // * Bullet List Item + // + // 1. Numbered List Item + // `; styledBlocks = [ { @@ -627,48 +626,48 @@ Paragraph }, ]; -// complexHTML = `

Heading 1

Heading 2

Heading 3

Paragraph

Paragraph

Paragraph

`; -// complexMarkdown = `# Heading 1 -// -// ## Heading 2 -// -// ### Heading 3 -// -// Paragraph -// -// P**ara***grap*h -// -// P*ara*~~grap~~h -// -// * Bullet List Item -// -// * Bullet List Item -// -// * Bullet List Item -// -// * Bullet List Item -// -// Paragraph -// -// 1. Numbered List Item -// -// 2. Numbered List Item -// -// 3. Numbered List Item -// -// 1. Numbered List Item -// -// * Bullet List Item -// -// * Bullet List Item -// -// * Bullet List Item -// `; + // complexHTML = `

Heading 1

Heading 2

Heading 3

Paragraph

Paragraph

Paragraph

`; + // complexMarkdown = `# Heading 1 + // + // ## Heading 2 + // + // ### Heading 3 + // + // Paragraph + // + // P**ara***grap*h + // + // P*ara*~~grap~~h + // + // * Bullet List Item + // + // * Bullet List Item + // + // * Bullet List Item + // + // * Bullet List Item + // + // Paragraph + // + // 1. Numbered List Item + // + // 2. Numbered List Item + // + // 3. Numbered List Item + // + // 1. Numbered List Item + // + // * Bullet List Item + // + // * Bullet List Item + // + // * Bullet List Item + // `; }); afterEach(() => { - editor._tiptapEditor.destroy() - editor = undefined; + editor._tiptapEditor.destroy(); + editor = undefined as any; delete (window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS; }); diff --git a/packages/core/test/__snapshots__/nodeConversions.test.ts.snap b/packages/core/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap similarity index 100% rename from packages/core/test/__snapshots__/nodeConversions.test.ts.snap rename to packages/core/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap diff --git a/packages/core/test/nodeConversions.test.ts b/packages/core/src/api/nodeConversions/nodeConversions.test.ts similarity index 94% rename from packages/core/test/nodeConversions.test.ts rename to packages/core/src/api/nodeConversions/nodeConversions.test.ts index a232b0104a..bb33e62bd3 100644 --- a/packages/core/test/nodeConversions.test.ts +++ b/packages/core/src/api/nodeConversions/nodeConversions.test.ts @@ -1,12 +1,10 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; -import { BlockNoteEditor, PartialBlock } from "../src"; -import { - blockToNode, - nodeToBlock, -} from "../src/api/nodeConversions/nodeConversions"; -import UniqueID from "../src/extensions/UniqueID/UniqueID"; +import { BlockNoteEditor, PartialBlock } from "../.."; +import { blockToNode, nodeToBlock } from "./nodeConversions"; + import { Editor } from "@tiptap/core"; import { Node } from "prosemirror-model"; +import UniqueID from "../../extensions/UniqueID/UniqueID"; let editor: Editor; @@ -120,7 +118,7 @@ beforeEach(() => { afterEach(() => { editor.destroy(); - editor = undefined; + editor = undefined as any; delete (window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS; });