Skip to content

Commit

Permalink
test: add tests for old format parser in capabilities (#3173)
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilmedina authored and github-actions[bot] committed Dec 13, 2024
1 parent 5baff8e commit c825a1d
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import com.wire.kalium.mocks.responses.ClientResponseJson
import com.wire.kalium.mocks.responses.RegisterClientRequestJson
import com.wire.kalium.mocks.responses.RegisterTokenJson
import com.wire.kalium.mocks.responses.UpdateClientRequestJson
import com.wire.kalium.network.api.base.authenticated.client.ClientApi
import com.wire.kalium.network.api.authenticated.client.ClientCapabilityDTO
import com.wire.kalium.network.api.authenticated.client.UpdateClientCapabilitiesRequest
import com.wire.kalium.network.api.base.authenticated.client.ClientApi
import com.wire.kalium.network.api.v0.authenticated.ClientApiV0
import com.wire.kalium.network.exceptions.KaliumException
import com.wire.kalium.network.utils.NetworkResponse
Expand Down Expand Up @@ -58,7 +58,26 @@ internal class ClientApiV0Test : ApiTest() {
val clientApi: ClientApi = ClientApiV0(networkClient)
val response = clientApi.registerClient(REGISTER_CLIENT_REQUEST.serializableData)
assertTrue(response.isSuccessful())
assertEquals(response.value, VALID_REGISTER_CLIENT_RESPONSE.serializableData)
assertEquals(VALID_REGISTER_CLIENT_RESPONSE.serializableData, response.value)
}

@Test
fun givenAValidRegisterClientRequest_whenCallingTheRegisterClientEndpointWithOldFormat_theRequestShouldBeConfiguredCorrectly() =
runTest {
val networkClient = mockAuthenticatedNetworkClient(
VALID_REGISTER_CLIENT_OLD_RESPONSE.rawJson,
statusCode = HttpStatusCode.Created,
assertion = {
assertPost()
assertJson()
assertNoQueryParams()
assertPathEqual(PATH_CLIENTS)
}
)
val clientApi: ClientApi = ClientApiV0(networkClient)
val response = clientApi.registerClient(REGISTER_CLIENT_REQUEST.serializableData)
assertTrue(response.isSuccessful())
assertEquals(VALID_REGISTER_CLIENT_OLD_RESPONSE.serializableData, response.value)
}

@Test
Expand Down Expand Up @@ -93,6 +112,7 @@ internal class ClientApiV0Test : ApiTest() {

assertTrue(response.isSuccessful())
}

@Test
fun givenAValidUpdateClientCapabilitiesRequest_whenCallingTheUpdateClientEndpoint_theRequestShouldBeConfiguredCorrectly() =
runTest {
Expand Down Expand Up @@ -172,6 +192,7 @@ internal class ClientApiV0Test : ApiTest() {
const val PATH_CLIENTS = "/clients"
val REGISTER_CLIENT_REQUEST = RegisterClientRequestJson.valid
val VALID_REGISTER_CLIENT_RESPONSE = ClientResponseJson.valid
val VALID_REGISTER_CLIENT_OLD_RESPONSE = ClientResponseJson.validCapabilitiesObject
val UPDATE_CLIENT_REQUEST = UpdateClientRequestJson.valid
val ERROR_RESPONSE = ErrorResponseJson.valid.serializableData
val VALID_PUSH_TOKEN_REQUEST = RegisterTokenJson.validPushTokenRequest
Expand Down

0 comments on commit c825a1d

Please sign in to comment.