diff --git a/package.json b/package.json index 1aef457..fa08524 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@matters/matters-editor", - "version": "0.2.3-alpha.2", + "version": "0.2.3-alpha.3", "description": "Editor for matters.news", "author": "https://github.com/thematters", "homepage": "https://github.com/thematters/matters-editor", diff --git a/src/transformers/normalize-sanitize.test.ts b/src/transformers/normalize-sanitize.test.ts index 6774330..a95b5da 100644 --- a/src/transformers/normalize-sanitize.test.ts +++ b/src/transformers/normalize-sanitize.test.ts @@ -6,9 +6,9 @@ import rehypeStringify from 'rehype-stringify' import { unified } from 'unified' import { describe, expect, test } from 'vitest' -import { normalizeArticleHTML } from './normalize' +import { normalizeArticleHTML, normalizeCommentHTML } from './normalize' import { rehypeParseOptions, rehypeStringifyOptions } from './options' -import { sanitizeHTML } from './sanitize' +import { sanitizeHTML, type SanitizeHTMLOptions } from './sanitize' const formatter = unified() .use(rehypeParse, rehypeParseOptions) @@ -21,15 +21,23 @@ const formatHTML = (html: string): string => { return String(result) } -const expectProcessArticleHTML = (input: string, output: string) => { - const result = normalizeArticleHTML(sanitizeHTML(input)) +const expectProcessArticleHTML = ( + input: string, + output: string, + options?: SanitizeHTMLOptions, +) => { + const result = normalizeArticleHTML(sanitizeHTML(input, options)) expect(formatHTML(result).trim()).toBe(output) } -// const expectProcessCommentHTML = (input: string, output: string) => { -// const result = normalizeCommentHTML(sanitizeHTML(input)) -// expect(formatHTML(result).trim()).toBe(output) -// } +const expectProcessCommentHTML = ( + input: string, + output: string, + options?: SanitizeHTMLOptions, +) => { + const result = normalizeCommentHTML(sanitizeHTML(input, options)) + expect(formatHTML(result).trim()).toBe(output) +} describe('Sanitize and normalize article', () => { test('squeeze empty paragraphys', () => { @@ -48,7 +56,6 @@ describe('Sanitize and normalize article', () => {
abc
+ + + abc + +abc
+ + + +abc
+ +abc
+ + +abc
+ +abc
+ + + +abc
+ +abc
@@ -75,20 +75,25 @@ describe('Sanitization: custom', () => {abc
-abc
-abc
+