diff --git a/package.json b/package.json index 750bb11..5ff5148 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@matters/matters-editor", - "version": "0.2.3-alpha.0", + "version": "0.2.3-alpha.1", "description": "Editor for matters.news", "author": "https://github.com/thematters", "homepage": "https://github.com/thematters/matters-editor", diff --git a/src/transformers/normalize.test.ts b/src/transformers/normalize.test.ts index e47c019..95c9f6a 100644 --- a/src/transformers/normalize.test.ts +++ b/src/transformers/normalize.test.ts @@ -1,16 +1,21 @@ import { describe, expect, test } from 'vitest' -import { normalizeArticleHTML } from './normalize' +import { normalizeArticleHTML, normalizeCommentHTML } from './normalize' const expectNormalizeArticleHTML = (input: string, output: string) => { const result = normalizeArticleHTML(input) expect(result.trim()).toBe(output) } +export const expectNormalizeCommentHTML = (input: string, output: string) => { + const result = normalizeCommentHTML(input) + expect(result.trim()).toBe(output) +} + /** * Tests */ -describe('Normalization', () => { +describe('Normalization: Article', () => { test('bolds', () => { expectNormalizeArticleHTML( '

abc

', @@ -279,3 +284,80 @@ describe('Normalization', () => { ) }) }) + +describe('Normalization: Comment', () => { + test('quote', () => { + expectNormalizeCommentHTML( + '

abc

', + '

abc

', + ) + }) + + test('link', () => { + expectNormalizeCommentHTML( + '

abc

', + '

abc

', + ) + }) + + test('bolds is not supported', () => { + expectNormalizeCommentHTML('

abc

', '

abc

') + expectNormalizeCommentHTML('

abc

', '

abc

') + }) + + test('strikethrough is not supported', () => { + expectNormalizeCommentHTML('

abc

', '

abc

') + expectNormalizeCommentHTML('

abc

', '

abc

') + expectNormalizeCommentHTML('

abc

', '

abc

') + }) + + test('italic is not supported', () => { + expectNormalizeCommentHTML('

abc

', '

abc

') + + expectNormalizeCommentHTML('

abc

', '

abc

') + }) + + test('underline is not supported', () => { + expectNormalizeCommentHTML('

abc

', '

abc

') + }) + + test('self-closed tags', () => { + expectNormalizeCommentHTML('

', '

') + + expectNormalizeCommentHTML('

', '


') + + expectNormalizeCommentHTML('
', '

') + + // -> + expectNormalizeCommentHTML( + '
左:女反派。右:女主。
', + '

左:女反派。右:女主。

', + ) + + // + expectNormalizeCommentHTML( + '
', + '

', + ) + }) +})