This repository has been archived by the owner on Dec 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Xerus
committed
Jul 27, 2019
1 parent
49317b6
commit 4116b5c
Showing
2 changed files
with
23 additions
and
10 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
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 |
---|---|---|
@@ -1,16 +1,30 @@ | ||
package xerus.monstercat.api | ||
|
||
import io.kotlintest.matchers.collections.shouldNotContain | ||
import io.kotlintest.inspectors.forAll | ||
import io.kotlintest.shouldBe | ||
import io.kotlintest.specs.StringSpec | ||
import xerus.monstercat.api.response.ArtistRel | ||
import kotlinx.coroutines.runBlocking | ||
import xerus.ktutil.printIt | ||
|
||
data class SongSearch(val searchTerm: String, val expectedTerm: String? = null) | ||
|
||
internal class APIUtilsTest: StringSpec({ | ||
|
||
"find Edge of the World by Karma Fields" { | ||
val edge = APIUtils.find("Edge Of The World", "Karma Fields")!! | ||
edge.artists shouldNotContain ArtistRel("Razihel") | ||
edge.artistsTitle shouldBe "Karma Fields" | ||
"APIUtils.find" { | ||
arrayOf( | ||
SongSearch("Karma Fields - Edge of the World"), | ||
SongSearch("Julian Calor - Monster (feat. Trove)", "Julian Calor feat. Trove - Monster"), | ||
SongSearch("Rootkit - Voyage (Kage Remix)") | ||
).forAll { | ||
runBlocking { | ||
val search = it.searchTerm.split(" - ") | ||
val result = APIUtils.find(search[1], search[0]) | ||
val expected = (it.expectedTerm ?: it.searchTerm).split(" - ", " (", ")") | ||
result shouldBe Cache.getTracks().find { | ||
it.artistsTitle == expected[0] && it.title == expected[1] && (expected.size < 3 || it.version == expected[2]) | ||
}.printIt() | ||
} | ||
} | ||
} | ||
|
||
}) |