-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Alexa md renderer to remove trailing periods. Added more tests. (
#237) * Change Alexa md renderer to remove trailing periods. Added more tests. * Fix link and quote md rendering Co-authored-by: Gary Pretty <gary@garypretty.co.uk>
- Loading branch information
1 parent
776bfd8
commit dacd16d
Showing
3 changed files
with
124 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
tests/Bot.Builder.Community.Adapters.Alexa.Tests/AlexaMarkdownToPlaintextRendererTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using Bot.Builder.Community.Adapters.Alexa.Core.Helpers; | ||
using Xunit; | ||
|
||
namespace Bot.Builder.Community.Adapters.Alexa.Tests | ||
{ | ||
public class AlexaMarkdownToPlaintextRendererTests | ||
{ | ||
[Fact] | ||
public void ConvertTextWithTrailingPeriod() | ||
{ | ||
var md = "Text text."; | ||
var result = AlexaMarkdownToPlaintextRenderer.Render(md); | ||
Assert.Equal(md, result); | ||
} | ||
|
||
[Fact] | ||
public void ConvertTextWithNoTrailingPeriod() | ||
{ | ||
var md = "Text text"; | ||
var result = AlexaMarkdownToPlaintextRenderer.Render(md); | ||
// Trailing period is added because it is a paragraph. Alexa TTS doesn't mind either way. | ||
Assert.Equal("Text text.", result); | ||
} | ||
|
||
[Fact] | ||
public void ConvertTextLeadingTrailingWhitespace() | ||
{ | ||
var md = " Text text "; | ||
var result = AlexaMarkdownToPlaintextRenderer.Render(md); | ||
Assert.Equal("Text text.", result); | ||
} | ||
|
||
[Fact] | ||
public void ConvertTextTrailingNewline() | ||
{ | ||
var md = "Text text\n"; | ||
var result = AlexaMarkdownToPlaintextRenderer.Render(md); | ||
Assert.Equal("Text text.", result); | ||
} | ||
|
||
[Fact] | ||
public void ConvertTextNoTrailingNewline() | ||
{ | ||
var md = "Text text"; | ||
var result = AlexaMarkdownToPlaintextRenderer.Render(md); | ||
Assert.Equal("Text text.", result); | ||
} | ||
|
||
[Fact] | ||
public void ConvertTextBrAndParagraphs() | ||
{ | ||
var md = "Same line.\nSame line. \n2nd line.\n\r3rd line."; | ||
var result = AlexaMarkdownToPlaintextRenderer.Render(md); | ||
Assert.Equal("Same line. Same line. 2nd line. 3rd line.", result); | ||
} | ||
|
||
[Fact] | ||
public void ConvertTextBrAndParagraphsNoSpacesBetween() | ||
{ | ||
var md = "Same line.\nSame line.\n2nd line.\n\r3rd line."; | ||
var result = AlexaMarkdownToPlaintextRenderer.Render(md); | ||
Assert.Equal("Same line. Same line. 2nd line. 3rd line.", result); | ||
} | ||
|
||
[Fact] | ||
public void ConvertQuotesAndUrls() | ||
{ | ||
var md = "{ \"contentType\": \"image/jpeg\", \"content\": \"https://somefantasticurl/\", \"name\": \"Attachment1.jpg\" }"; | ||
var result = AlexaMarkdownToPlaintextRenderer.Render(md); | ||
Assert.Equal("{ \"contentType\": \"image/jpeg\", \"content\": \"https://somefantasticurl/\", \"name\": \"Attachment1.jpg\" }.", result); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters