-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cherry-picked 5cf2e75]
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package dotty.tools.scaladoc | ||
|
||
import org.junit.Test | ||
import org.junit.Assert._ | ||
import dotty.tools.scaladoc.SocialLinks | ||
|
||
class SocialLinksTest: | ||
|
||
@Test def githubLink(): Unit = | ||
val githubLink = "github::https://github.com/test" | ||
val expected = SocialLinks.Github("https://github.com/test") | ||
assertEquals(expected, SocialLinks.parse(githubLink).getOrElse(null)) | ||
|
||
@Test def twitterLink(): Unit = | ||
val twitterLink = "twitter::https://twitter.com/test" | ||
val expected = SocialLinks.Twitter("https://twitter.com/test") | ||
assertEquals(expected, SocialLinks.parse(twitterLink).getOrElse(null)) | ||
|
||
@Test def gitterLink(): Unit = | ||
val gitterLink = "gitter::https://gitter.im/test" | ||
val expected = SocialLinks.Gitter("https://gitter.im/test") | ||
assertEquals(expected, SocialLinks.parse(gitterLink).getOrElse(null)) | ||
|
||
@Test def discordLink(): Unit = | ||
val discordLink = "discord::https://discord.gg/test" | ||
val expected = SocialLinks.Discord("https://discord.gg/test") | ||
assertEquals(expected, SocialLinks.parse(discordLink).getOrElse(null)) | ||
|
||
@Test def customLinkLight(): Unit = | ||
val customLink = "namecustom::https://custom.com/test::custom" | ||
val expected = SocialLinks.Custom("https://custom.com/test", "custom", "custom") | ||
assertEquals(expected, SocialLinks.parse(customLink).getOrElse(null)) | ||
|
||
@Test def customLinkLightAndDark(): Unit = | ||
val customLink = "namecustom::https://custom.com/test::custom::custom-dark" | ||
val expected = SocialLinks.Custom("https://custom.com/test", "custom", "custom-dark") | ||
assertEquals(expected, SocialLinks.parse(customLink).getOrElse(null)) | ||
|
||
@Test def parseRegexError(): Unit = | ||
val regexErrorLink = "nameCustom::https://custom.com/test::custom::custom-dark::custom" | ||
val expected = s"Social links arg $regexErrorLink is invalid: " | ||
assertEquals(expected, SocialLinks.parse(regexErrorLink).left.getOrElse(null)) | ||
|
||
@Test def parseLinkWithError(): Unit = | ||
val errorLink = "namecustom::https://custom.com/test::custom::custom-dark::custom" | ||
val expected = s"Social links arg $errorLink is invalid: For 'custom' two minimum arguments are expected: url, white icon name, [dark icon name]" | ||
assertEquals(expected, SocialLinks.parse(errorLink).left.getOrElse(null)) |