Skip to content

Commit

Permalink
add correct test agoda-com#6
Browse files Browse the repository at this point in the history
  • Loading branch information
HeyAlex committed Aug 26, 2019
1 parent 6263e2f commit 79b7fcc
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions ninjato-core/src/test/kotlin/com.agoda.ninjato/http/BodyTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,27 @@ class BodyTest {

// Assert
assert((delegate as Body).asString == "testify_body")
}

// Act
delegate = formUrlEncoded {
@Test
fun testExtension() {
val config = Request.Configurator.WithBody()

//FormUrlEncoded Extension
val formUrlEncodedBody = config.formUrlEncoded {
"a" to "test param !"
"b" to "c"
}

// Assert
assert((delegate as Body).asString == "a=test+param+%21&b=c")
assert((delegate as Body).mediaType is MediaType.FormUrlEncoded)
assert(formUrlEncodedBody.asString == "a=test+param+%21&b=c")
assert(formUrlEncodedBody.mediaType is MediaType.FormUrlEncoded)

// Act
//File Extension
val temp = createTempFile()
temp.writeBytes(byteArrayOf(0, 1, 2, 3, 4, 5))
delegate = file(temp, MediaType.Gif())

// Assert
assert((delegate as Body).asByteArray.contentEquals(byteArrayOf(0, 1, 2, 3, 4, 5)))
assert((delegate as Body).mediaType is MediaType.Gif)

val fileBody = config.file(temp, MediaType.Gif())
assert(fileBody.asByteArray.contentEquals(byteArrayOf(0, 1, 2, 3, 4, 5)))
assert(fileBody.mediaType is MediaType.Gif)
}

}

0 comments on commit 79b7fcc

Please sign in to comment.