-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly pass back token for push provisioning yellow path on a…
…ndroid (#1282)
- Loading branch information
1 parent
681d82b
commit 7a4c850
Showing
4 changed files
with
110 additions
and
33 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
76 changes: 76 additions & 0 deletions
76
android/src/androidTest/java/com/reactnativestripesdk/mappers/MappersTest.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,76 @@ | ||
package com.reactnativestripesdk.mappers | ||
|
||
import android.content.Context | ||
import androidx.test.core.app.ApplicationProvider | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.WritableNativeMap | ||
import com.facebook.soloader.SoLoader | ||
import com.reactnativestripesdk.utils.createCanAddCardResult | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class MappersTest { | ||
private val reactApplicationContext = ReactApplicationContext( | ||
ApplicationProvider.getApplicationContext<Context>() | ||
) | ||
|
||
@Before | ||
fun setup(){ | ||
SoLoader.init(reactApplicationContext, false) | ||
} | ||
|
||
|
||
@Test | ||
fun createCanAddCardResult_NoStatus() { | ||
val result = createCanAddCardResult( | ||
true, | ||
null, | ||
null | ||
) | ||
Assert.assertNotNull(result.getMap("details")) | ||
Assert.assertNull(result.getMap("details")?.getString("status")) | ||
Assert.assertNull(result.getMap("details")?.getMap("token")) | ||
Assert.assertTrue(result.getBoolean("canAddCard")) | ||
} | ||
|
||
@Test | ||
fun createCanAddCardResult_WithToken() { | ||
val result = createCanAddCardResult( | ||
true, | ||
"CARD_ALREADY_EXISTS", | ||
WritableNativeMap().also { it.putString("key", "value") } | ||
) | ||
Assert.assertTrue(result.getBoolean("canAddCard")) | ||
val details = result.getMap("details") | ||
Assert.assertEquals(details?.getString("status"), "CARD_ALREADY_EXISTS") | ||
Assert.assertEquals(details?.getMap("token")?.getString("key"), "value") | ||
} | ||
|
||
@Test | ||
fun createCanAddCardResult_UnsupportedDevice() { | ||
val result = createCanAddCardResult( | ||
false, | ||
"UNSUPPORTED_DEVICE", | ||
null | ||
) | ||
Assert.assertFalse(result.getBoolean("canAddCard")) | ||
val details = result.getMap("details") | ||
Assert.assertEquals(details?.getString("status"), "UNSUPPORTED_DEVICE") | ||
Assert.assertNull(details?.getMap("token")) | ||
} | ||
|
||
@Test | ||
fun createCanAddCardResult_MissingConfiguration() { | ||
val result = createCanAddCardResult( | ||
false, | ||
"MISSING_CONFIGURATION", | ||
null | ||
) | ||
Assert.assertFalse(result.getBoolean("canAddCard")) | ||
val details = result.getMap("details") | ||
Assert.assertEquals(details?.getString("status"), "MISSING_CONFIGURATION") | ||
Assert.assertNull(details?.getMap("token")) | ||
} | ||
} | ||
|
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