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
class InstagramErrorByTypeTest { | |
companion object { | |
@Suppress("unused") | |
@JvmStatic | |
private fun checkSealedClassesByType() = Stream.of( | |
Arguments.of( | |
InstagramErrorType.DeclinePost( | |
photoVideoUrl = "https://www.instagram.com/p/B_2B2nwpS5g/", | |
tags = listOf("pullup", "bodyweight"), | |
errorCode = ErrorCode.Declined, | |
textContent = "Content", | |
location = "Venice Beach" | |
), InstagramErrorType.DeclinePost::class | |
), | |
Arguments.of( | |
InstagramErrorType.TooLongVideoPost( | |
photoVideoUrl = "https://www.instagram.com/tv/B9j2CshJr9u/", | |
tags = listOf("tutorial", "handstand"), | |
errorCode = ErrorCode.OverLimit, | |
textContent = "Content", | |
location = "London, United Kingdom" | |
), InstagramErrorType.TooLongVideoPost::class | |
), | |
Arguments.of( | |
InstagramErrorType.TimeoutStory( | |
photoVideoUrl = "https://www.instagram.com/p/B3aHttphr9V/", | |
tags = listOf("pullup", "bodyweight"), | |
errorCode = ErrorCode.TimeOut, | |
texts = listOf("Title", "Subtitle") | |
), InstagramErrorType.TimeoutStory::class | |
), | |
Arguments.of( | |
InstagramErrorType.TooShortIGTvPost( | |
photoVideoUrl = "https://www.instagram.com/tv/B9MZ3iDptJi/", | |
tags = listOf("core", "bodyWeight"), | |
errorCode = ErrorCode.OverLimit, | |
textContent = "CORE CHALLENGE" | |
), | |
InstagramErrorType.TooShortIGTvPost::class | |
), | |
Arguments.of( | |
InstagramErrorType.TimeOutIGTvPost( | |
photoVideoUrl = "https://www.instagram.com/tv/B_hccoAjjiQ/", | |
tags = listOf("core", "bodyweight"), | |
errorCode = ErrorCode.TimeOut, | |
textContent = "Flexibility Helpers" | |
), | |
InstagramErrorType.TimeOutIGTvPost::class | |
) | |
) | |
} | |
@ParameterizedTest | |
@MethodSource("checkSealedClassesByType") | |
fun <I : InstagramErrorType> `can check sealed classes by type`( | |
instagramError: InstagramErrorType, | |
expectedSealedClass: KClass<I> | |
) { | |
Assertions.assertEquals(instagramError::class.simpleName!!, expectedSealedClass.simpleName) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment