-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
6620c87
commit 418902b
Showing
5 changed files
with
82 additions
and
26 deletions.
There are no files selected for viewing
File renamed without changes.
39 changes: 39 additions & 0 deletions
39
shared/src/commonTest/kotlin/com/example/kmptemplate/Test.kt
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,39 @@ | ||
package com.example.kmptemplate | ||
|
||
import Greeting | ||
import io.ktor.client.* | ||
import io.ktor.client.plugins.contentnegotiation.* | ||
import io.ktor.http.* | ||
import io.ktor.serialization.kotlinx.json.* | ||
import io.ktor.utils.io.* | ||
import kotlinx.coroutines.test.runTest | ||
import kotlinx.serialization.json.Json | ||
import kotlin.test.Test | ||
import kotlin.test.assertTrue | ||
|
||
class CommonGreetingTest { | ||
|
||
fun testExample() { | ||
runTest{ | ||
val mockEngine = MockEngine { request -> | ||
respond( | ||
content = ByteReadChannel("""[{"name":"CTS21","flight_number":42,"success":true,"date_utc":"2021-09-15T00:00:00Z"}]"""), | ||
status = HttpStatusCode.OK, | ||
headers = headersOf(HttpHeaders.ContentType, ContentType.Application.Json.toString()) | ||
) | ||
} | ||
|
||
val mockHttpClient = HttpClient(mockEngine) { | ||
install(ContentNegotiation) { | ||
json(Json { | ||
prettyPrint = true | ||
isLenient = true | ||
ignoreUnknownKeys = true | ||
}) | ||
} | ||
} | ||
assertTrue("Check 2021-09 is mentioned", Greeting(mockHttpClient).greet().contains("Greetings!")) | ||
|
||
} | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
shared/src/commonTest/kotlin/com/example/leveldetektor/Test.kt
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
shared/src/iosTest/kotlin/com/example/kmptemplate/Test.ios.kt
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,43 @@ | ||
package com.example.kmptemplate | ||
|
||
import Greeting | ||
import io.ktor.client.* | ||
import io.ktor.client.engine.mock.* | ||
import io.ktor.client.plugins.contentnegotiation.* | ||
import io.ktor.http.* | ||
import io.ktor.serialization.kotlinx.json.* | ||
import io.ktor.utils.io.* | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import kotlinx.coroutines.test.runTest | ||
import kotlinx.serialization.json.Json | ||
import kotlin.test.Test | ||
import kotlin.test.assertTrue | ||
|
||
class IosGreetingTest { | ||
|
||
@OptIn(ExperimentalCoroutinesApi::class) | ||
@Test | ||
fun testExample() { | ||
runTest{ | ||
val mockEngine = MockEngine { request -> | ||
respond( | ||
content = ByteReadChannel("""[{"name":"CTS21","flight_number":42,"success":true,"date_utc":"2021-09-15T00:00:00Z"}]"""), | ||
status = HttpStatusCode.OK, | ||
headers = headersOf(HttpHeaders.ContentType, ContentType.Application.Json.toString()) | ||
) | ||
} | ||
|
||
val mockHttpClient = HttpClient(mockEngine) { | ||
install(ContentNegotiation) { | ||
json(Json { | ||
prettyPrint = true | ||
isLenient = true | ||
ignoreUnknownKeys = true | ||
}) | ||
} | ||
} | ||
assertTrue("Check 2021-09 is mentioned", Greeting(mockHttpClient).greet().contains("Greetings!")) | ||
|
||
} | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
shared/src/iosTest/kotlin/com/example/leveldetektor/Test.ios.kt
This file was deleted.
Oops, something went wrong.