|
| 1 | +package dotty.tools.scaladoc |
| 2 | + |
| 3 | +import org.junit.Test |
| 4 | +import org.junit.Assert._ |
| 5 | +import dotty.tools.scaladoc.SocialLinks |
| 6 | + |
| 7 | +class SocialLinksTest: |
| 8 | + |
| 9 | + @Test def githubLink(): Unit = |
| 10 | + val githubLink = "github::https://github.com/test" |
| 11 | + val expected = SocialLinks.Github("https://github.com/test") |
| 12 | + assertEquals(expected, SocialLinks.parse(githubLink).getOrElse(null)) |
| 13 | + |
| 14 | + @Test def twitterLink(): Unit = |
| 15 | + val twitterLink = "twitter::https://twitter.com/test" |
| 16 | + val expected = SocialLinks.Twitter("https://twitter.com/test") |
| 17 | + assertEquals(expected, SocialLinks.parse(twitterLink).getOrElse(null)) |
| 18 | + |
| 19 | + @Test def gitterLink(): Unit = |
| 20 | + val gitterLink = "gitter::https://gitter.im/test" |
| 21 | + val expected = SocialLinks.Gitter("https://gitter.im/test") |
| 22 | + assertEquals(expected, SocialLinks.parse(gitterLink).getOrElse(null)) |
| 23 | + |
| 24 | + @Test def discordLink(): Unit = |
| 25 | + val discordLink = "discord::https://discord.gg/test" |
| 26 | + val expected = SocialLinks.Discord("https://discord.gg/test") |
| 27 | + assertEquals(expected, SocialLinks.parse(discordLink).getOrElse(null)) |
| 28 | + |
| 29 | + @Test def customLinkLight(): Unit = |
| 30 | + val customLink = "namecustom::https://custom.com/test::custom" |
| 31 | + val expected = SocialLinks.Custom("https://custom.com/test", "custom", "custom") |
| 32 | + assertEquals(expected, SocialLinks.parse(customLink).getOrElse(null)) |
| 33 | + |
| 34 | + @Test def customLinkLightAndDark(): Unit = |
| 35 | + val customLink = "namecustom::https://custom.com/test::custom::custom-dark" |
| 36 | + val expected = SocialLinks.Custom("https://custom.com/test", "custom", "custom-dark") |
| 37 | + assertEquals(expected, SocialLinks.parse(customLink).getOrElse(null)) |
| 38 | + |
| 39 | + @Test def parseRegexError(): Unit = |
| 40 | + val regexErrorLink = "nameCustom::https://custom.com/test::custom::custom-dark::custom" |
| 41 | + val expected = s"Social links arg $regexErrorLink is invalid: " |
| 42 | + assertEquals(expected, SocialLinks.parse(regexErrorLink).left.getOrElse(null)) |
| 43 | + |
| 44 | + @Test def parseLinkWithError(): Unit = |
| 45 | + val errorLink = "namecustom::https://custom.com/test::custom::custom-dark::custom" |
| 46 | + val expected = s"Social links arg $errorLink is invalid: For 'custom' two minimum arguments are expected: url, white icon name, [dark icon name]" |
| 47 | + assertEquals(expected, SocialLinks.parse(errorLink).left.getOrElse(null)) |
0 commit comments