From: 丶远方 Date: Fri, 10 Nov 2023 07:07:24 +0000 (+0800) Subject: test(shared): add test case for escapeHtmlComment (#8065) X-Git-Tag: v3.3.9~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa65cb6af1e8b126c2b340f71274b8b9dea26c88;p=thirdparty%2Fvuejs%2Fcore.git test(shared): add test case for escapeHtmlComment (#8065) --- diff --git a/packages/shared/__tests__/escapeHtml.spec.ts b/packages/shared/__tests__/escapeHtml.spec.ts index 34505d3ead..30004706af 100644 --- a/packages/shared/__tests__/escapeHtml.spec.ts +++ b/packages/shared/__tests__/escapeHtml.spec.ts @@ -1,11 +1,31 @@ -import { escapeHtml } from '../src' - -test('ssr: escapeHTML', () => { - expect(escapeHtml(`foo`)).toBe(`foo`) - expect(escapeHtml(true)).toBe(`true`) - expect(escapeHtml(false)).toBe(`false`) - expect(escapeHtml(`a && b`)).toBe(`a && b`) - expect(escapeHtml(`"foo"`)).toBe(`"foo"`) - expect(escapeHtml(`'bar'`)).toBe(`'bar'`) - expect(escapeHtml(`
`)).toBe(`<div>`) +import { escapeHtml, escapeHtmlComment } from '../src' + +describe('escapeHtml', () => { + test('ssr: escapeHTML', () => { + expect(escapeHtml(`foo`)).toBe(`foo`) + expect(escapeHtml(true)).toBe(`true`) + expect(escapeHtml(false)).toBe(`false`) + expect(escapeHtml(`a && b`)).toBe(`a && b`) + expect(escapeHtml(`"foo"`)).toBe(`"foo"`) + expect(escapeHtml(`'bar'`)).toBe(`'bar'`) + expect(escapeHtml(`
`)).toBe(`<div>`) + }) + + test('ssr: escapeHTMLComment', () => { + const input = '' + const result = escapeHtmlComment(input) + expect(result).toEqual(' Hello World! ') + }) + + test('ssr: escapeHTMLComment', () => { + const input = ' Hello World!' + const result = escapeHtmlComment(input) + expect(result).toEqual(' Comment 1 Hello ! Comment 2 World!') + }) + + test('should not affect non-comment strings', () => { + const input = 'Hello World' + const result = escapeHtmlComment(input) + expect(result).toEqual(input) + }) })