From e8eaafb5100644472225d23409f07d92bdee9804 Mon Sep 17 00:00:00 2001 From: William Wong Date: Fri, 3 May 2024 08:46:38 +0000 Subject: [PATCH] Add newline to end of XML serialization --- ...ty.adaptiveCard.hack.activeElementMod.html | 4 +-- ...ty.adaptiveCard.hack.persistValuesMod.html | 4 +-- .../src/__tests__/renderMarkdown.spec.js | 36 +++++++++---------- .../betterLinkDocumentMod.ariaLabel.spec.ts | 4 +-- .../betterLinkDocumentMod.asButton.spec.ts | 10 +++--- .../betterLinkDocumentMod.className.spec.ts | 4 +-- ...etterLinkDocumentMod.iconClassName.spec.ts | 2 +- .../private/betterLinkDocumentMod.rel.spec.ts | 4 +-- .../betterLinkDocumentMod.selector.spec.ts | 4 +-- .../betterLinkDocumentMod.target.spec.ts | 4 +-- .../betterLinkDocumentMod.title.spec.ts | 4 +-- ...LinkDocumentMod.wrapZeroWidthSpace.spec.ts | 4 +-- .../src/Utils/serializeDocumentIntoString.ts | 2 +- 13 files changed, 43 insertions(+), 43 deletions(-) diff --git a/__tests__/html/accessibility.adaptiveCard.hack.activeElementMod.html b/__tests__/html/accessibility.adaptiveCard.hack.activeElementMod.html index c825af3f11..102f4999b3 100644 --- a/__tests__/html/accessibility.adaptiveCard.hack.activeElementMod.html +++ b/__tests__/html/accessibility.adaptiveCard.hack.activeElementMod.html @@ -35,7 +35,7 @@ await pageConditions.numActivitiesShown(1); - expect(pageElements.activityContents()[0]).toHaveProperty('textContent', 'Hello, World!'); + expect(pageElements.activityContents()[0]).toHaveProperty('textContent', 'Hello, World!\n'); const pushButton1 = document.querySelector('.ac-pushButton'); @@ -53,7 +53,7 @@ type: 'message' }); - expect(pageElements.activityContents()[0]).toHaveProperty('textContent', 'Aloha!'); + expect(pageElements.activityContents()[0]).toHaveProperty('textContent', 'Aloha!\n'); const pushButton2 = document.querySelector('.ac-pushButton'); diff --git a/__tests__/html/accessibility.adaptiveCard.hack.persistValuesMod.html b/__tests__/html/accessibility.adaptiveCard.hack.persistValuesMod.html index 8b5d32b89d..d6e7a0b8ca 100644 --- a/__tests__/html/accessibility.adaptiveCard.hack.persistValuesMod.html +++ b/__tests__/html/accessibility.adaptiveCard.hack.persistValuesMod.html @@ -45,7 +45,7 @@ await pageConditions.numActivitiesShown(1); - expect(pageElements.activityContents()[0]).toHaveProperty('textContent', 'Hello, World!'); + expect(pageElements.activityContents()[0]).toHaveProperty('textContent', 'Hello, World!\n'); const textInput1 = document.querySelector('.ac-textInput'); @@ -62,7 +62,7 @@ type: 'message' }); - expect(pageElements.activityContents()[0]).toHaveProperty('textContent', 'Aloha!'); + expect(pageElements.activityContents()[0]).toHaveProperty('textContent', 'Aloha!\n'); const textInput2 = document.querySelector('.ac-textInput'); diff --git a/packages/bundle/src/__tests__/renderMarkdown.spec.js b/packages/bundle/src/__tests__/renderMarkdown.spec.js index 688999761b..eb01babb16 100644 --- a/packages/bundle/src/__tests__/renderMarkdown.spec.js +++ b/packages/bundle/src/__tests__/renderMarkdown.spec.js @@ -14,7 +14,7 @@ describe('renderMarkdown', () => { const styleOptions = { markdownRespectCRLF: true }; expect(renderMarkdown('Same line.\nSame line. \n2nd line.', styleOptions)).toBe( - '

Same line.\nSame line.
\n2nd line.

' + '

Same line.\nSame line.
\n2nd line.

\n' ); }); @@ -22,7 +22,7 @@ describe('renderMarkdown', () => { const styleOptions = { markdownRespectCRLF: true }; expect(renderMarkdown('Same Line.\n\rSame Line.\r\n2nd line.', styleOptions)).toBe( - '

Same Line.\nSame Line.

\n

2nd line.

' + '

Same Line.\nSame Line.

\n

2nd line.

\n' ); }); @@ -30,7 +30,7 @@ describe('renderMarkdown', () => { const styleOptions = { markdownRespectCRLF: false }; expect(renderMarkdown('Same Line.\r\nSame Line.\n\r2nd line.', styleOptions)).toBe( - '

Same Line.\nSame Line.

\n

2nd line.

' + '

Same Line.\nSame Line.

\n

2nd line.

\n' ); }); @@ -38,7 +38,7 @@ describe('renderMarkdown', () => { const styleOptions = { markdownRespectCRLF: true }; expect(renderMarkdown('**Message with Markdown**\r\nShould see bold text.', styleOptions)).toBe( - '

Message with Markdown

\n

Should see bold text.

' + '

Message with Markdown

\n

Should see bold text.

\n' ); }); @@ -46,36 +46,36 @@ describe('renderMarkdown', () => { const styleOptions = { markdownRespectCRLF: true }; expect(renderMarkdown(`\`\`\`\n${JSON.stringify({ hello: 'World!' }, null, 2)}\n\`\`\``, styleOptions)).toBe( - '
{\n  "hello": "World!"\n}\n
' + '
{\n  "hello": "World!"\n}\n
\n' ); }); it('should render aria-labels', () => { const styleOptions = { markdownRespectCRLF: true }; - expect( - renderMarkdown('[example](https://sample.com){aria-label="Sample label"}', styleOptions) - ).toMatchInlineSnapshot( - `"

\u200Bexample\u200B

"` - ); + expect(renderMarkdown('[example](https://sample.com){aria-label="Sample label"}', styleOptions)) + .toMatchInlineSnapshot(` + "

\u200Bexample\u200B

+ " + `); }); it('should render "open in new window" icon', () => { const styleOptions = { markdownRespectCRLF: true }; const options = { externalLinkAlt: 'Opens in a new window, external.' }; - expect( - renderMarkdown('[example](https://sample.com){aria-label="Sample label"}', styleOptions, options) - ).toMatchInlineSnapshot( - `"

\u200Bexample\u200B

"` - ); + expect(renderMarkdown('[example](https://sample.com){aria-label="Sample label"}', styleOptions, options)) + .toMatchInlineSnapshot(` + "

\u200Bexample\u200B

+ " + `); }); it('should render sip protocol links correctly', () => { const styleOptions = { markdownRespectCRLF: true }; expect(renderMarkdown(`[example@test.com](sip:example@test.com)`, styleOptions)).toBe( - '

\u200Bexample@test.com\u200B

' + '

\u200Bexample@test.com\u200B

\n' ); }); @@ -83,13 +83,13 @@ describe('renderMarkdown', () => { const styleOptions = { markdownRespectCRLF: true }; expect(renderMarkdown(`[(505)503-4455](tel:505-503-4455)`, styleOptions)).toBe( - '

\u200B(505)503-4455\u200B

' + '

\u200B(505)503-4455\u200B

\n' ); }); it('should render strikethrough text correctly', () => { const styleOptions = { markdownRespectCRLF: true }; - expect(renderMarkdown(`~~strike text~~`, styleOptions)).toBe('

strike text

'); + expect(renderMarkdown(`~~strike text~~`, styleOptions)).toBe('

strike text

\n'); }); }); diff --git a/packages/bundle/src/markdown/private/betterLinkDocumentMod.ariaLabel.spec.ts b/packages/bundle/src/markdown/private/betterLinkDocumentMod.ariaLabel.spec.ts index d1febbd17b..a33fcf4347 100644 --- a/packages/bundle/src/markdown/private/betterLinkDocumentMod.ariaLabel.spec.ts +++ b/packages/bundle/src/markdown/private/betterLinkDocumentMod.ariaLabel.spec.ts @@ -21,7 +21,7 @@ describe('When passing "ariaLabel" option with "Hello, World!"', () => { test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

Example

' + '

Example

\n' )); test('should match baseline', () => @@ -48,6 +48,6 @@ describe('When passing "ariaLabel" option with false', () => { test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - 'Example' + 'Example\n' )); }); diff --git a/packages/bundle/src/markdown/private/betterLinkDocumentMod.asButton.spec.ts b/packages/bundle/src/markdown/private/betterLinkDocumentMod.asButton.spec.ts index 6760857e43..ac8fc34fb3 100644 --- a/packages/bundle/src/markdown/private/betterLinkDocumentMod.asButton.spec.ts +++ b/packages/bundle/src/markdown/private/betterLinkDocumentMod.asButton.spec.ts @@ -21,7 +21,7 @@ describe('When passing "asButton" option with true', () => { test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

' + '

\n' )); test('should match baseline', () => @@ -45,7 +45,7 @@ describe('When passing "asButton" option with true and "iconClassName" with "my- test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

' + '

\n' )); test('should match baseline', () => @@ -71,7 +71,7 @@ describe('When passing "asButton" option with true and "title" with "Hello, Worl test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

' + '

\n' )); test('should match baseline', () => @@ -97,7 +97,7 @@ describe('When passing "asButton" option with true and "className" with "my-link test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

' + '

\n' )); test('should match baseline', () => @@ -123,7 +123,7 @@ describe('When passing "asButton" option with true and "aria-label" with "Hello, test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

' + '

\n' )); test('should match baseline', () => diff --git a/packages/bundle/src/markdown/private/betterLinkDocumentMod.className.spec.ts b/packages/bundle/src/markdown/private/betterLinkDocumentMod.className.spec.ts index 2a21064d2e..eba5302b7a 100644 --- a/packages/bundle/src/markdown/private/betterLinkDocumentMod.className.spec.ts +++ b/packages/bundle/src/markdown/private/betterLinkDocumentMod.className.spec.ts @@ -21,7 +21,7 @@ describe('When passing "className" option with "my-link"', () => { test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

Example

' + '

Example

\n' )); test('should match baseline', () => @@ -48,6 +48,6 @@ describe('When passing "className" option with false', () => { test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - 'Example' + 'Example\n' )); }); diff --git a/packages/bundle/src/markdown/private/betterLinkDocumentMod.iconClassName.spec.ts b/packages/bundle/src/markdown/private/betterLinkDocumentMod.iconClassName.spec.ts index eff1c6587d..0b07294b0c 100644 --- a/packages/bundle/src/markdown/private/betterLinkDocumentMod.iconClassName.spec.ts +++ b/packages/bundle/src/markdown/private/betterLinkDocumentMod.iconClassName.spec.ts @@ -32,7 +32,7 @@ describe('When passing "iconAlt" option with "Hello, World!" and "iconClassName" test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

Example

' + '

Example

\n' )); test('should match baseline', () => diff --git a/packages/bundle/src/markdown/private/betterLinkDocumentMod.rel.spec.ts b/packages/bundle/src/markdown/private/betterLinkDocumentMod.rel.spec.ts index e9f9995697..2a1d466a62 100644 --- a/packages/bundle/src/markdown/private/betterLinkDocumentMod.rel.spec.ts +++ b/packages/bundle/src/markdown/private/betterLinkDocumentMod.rel.spec.ts @@ -21,7 +21,7 @@ describe('When passing "rel" option with "noopener noreferer"', () => { test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

Example

' + '

Example

\n' )); test('should match baseline', () => @@ -47,6 +47,6 @@ describe('When passing "rel" option with false', () => { test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - 'Example' + 'Example\n' )); }); diff --git a/packages/bundle/src/markdown/private/betterLinkDocumentMod.selector.spec.ts b/packages/bundle/src/markdown/private/betterLinkDocumentMod.selector.spec.ts index 2f0b66ae56..470540f408 100644 --- a/packages/bundle/src/markdown/private/betterLinkDocumentMod.selector.spec.ts +++ b/packages/bundle/src/markdown/private/betterLinkDocumentMod.selector.spec.ts @@ -24,7 +24,7 @@ describe('When passing "ariaLabel" option with "Hello, World!" for a specific an test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

Hello, World!

\n

Aloha!

' + '

Hello, World!

\n

Aloha!

\n' )); test('should match baseline', () => @@ -55,7 +55,7 @@ describe('When passing "ariaLabel" option with "Hello, World!" for a specific an test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

Hello, World!

\n

Aloha!

' + '

Hello, World!

\n

Aloha!

\n' )); test('should match baseline', () => diff --git a/packages/bundle/src/markdown/private/betterLinkDocumentMod.target.spec.ts b/packages/bundle/src/markdown/private/betterLinkDocumentMod.target.spec.ts index b4a784e189..4094ae3dad 100644 --- a/packages/bundle/src/markdown/private/betterLinkDocumentMod.target.spec.ts +++ b/packages/bundle/src/markdown/private/betterLinkDocumentMod.target.spec.ts @@ -21,7 +21,7 @@ describe('When passing "target" option with "noopener noreferer"', () => { test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

Example

' + '

Example

\n' )); test('should match baseline', () => @@ -48,6 +48,6 @@ describe('When passing "target" option with false', () => { test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - 'Example' + 'Example\n' )); }); diff --git a/packages/bundle/src/markdown/private/betterLinkDocumentMod.title.spec.ts b/packages/bundle/src/markdown/private/betterLinkDocumentMod.title.spec.ts index 911db3a16b..82ef7a567c 100644 --- a/packages/bundle/src/markdown/private/betterLinkDocumentMod.title.spec.ts +++ b/packages/bundle/src/markdown/private/betterLinkDocumentMod.title.spec.ts @@ -21,7 +21,7 @@ describe('When passing "title" option with "Hello, World!"', () => { test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

Example

' + '

Example

\n' )); test('should match baseline', () => @@ -48,6 +48,6 @@ describe('When passing "title" option with false', () => { test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - 'Example' + 'Example\n' )); }); diff --git a/packages/bundle/src/markdown/private/betterLinkDocumentMod.wrapZeroWidthSpace.spec.ts b/packages/bundle/src/markdown/private/betterLinkDocumentMod.wrapZeroWidthSpace.spec.ts index 9bd7ddd827..2929b09aa3 100644 --- a/packages/bundle/src/markdown/private/betterLinkDocumentMod.wrapZeroWidthSpace.spec.ts +++ b/packages/bundle/src/markdown/private/betterLinkDocumentMod.wrapZeroWidthSpace.spec.ts @@ -18,7 +18,7 @@ describe('When passing "wrapZeroWidthSpace" option with true', () => { test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

\u200bExample\u200b

' + '

\u200bExample\u200b

\n' )); test('should match baseline', () => @@ -39,7 +39,7 @@ describe('When passing "wrapZeroWidthSpace" option with true and "asButton" opti test('should match snapshot', () => expect(serializeDocumentIntoString(actual)).toBe( - '

\u200b\u200b

' + '

\u200b\u200b

\n' )); test('should match baseline', () => diff --git a/packages/component/src/Utils/serializeDocumentIntoString.ts b/packages/component/src/Utils/serializeDocumentIntoString.ts index 9f33c03f98..66aa74cab0 100644 --- a/packages/component/src/Utils/serializeDocumentIntoString.ts +++ b/packages/component/src/Utils/serializeDocumentIntoString.ts @@ -6,5 +6,5 @@ export default function serializeDocumentIntoString(document: Document): string elementHTML.push(serializer.serializeToString(element)); } - return elementHTML.join('\n'); + return `${elementHTML.join('\n')}\n`; }