mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
feat: migrate ShareModuleTest to AssertJ (#45789)
Summary: Issue: https://github.com/facebook/react-native/issues/45596 ## Changelog: [ANDROID] [CHANGED] - Migrated `ShareModuleTest` from junit.Assert to assertj.core.api.Assertions. Pull Request resolved: https://github.com/facebook/react-native/pull/45789 Test Plan: Run `./gradlew test` Reviewed By: sammy-SC Differential Revision: D60379426 Pulled By: cortinico fbshipit-source-id: b49fca7aafd42a4207c76d51641caaa2e2511dc3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d32444600c
commit
e2d9ff8538
+12
-12
@@ -14,8 +14,7 @@ import com.facebook.react.bridge.Promise
|
||||
import com.facebook.react.bridge.ReactTestHelper
|
||||
import com.facebook.react.bridge.WritableMap
|
||||
import com.facebook.testutils.shadows.ShadowArguments
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -57,17 +56,18 @@ class ShareModuleTest {
|
||||
shareModule.share(content, dialogTitle, promise)
|
||||
|
||||
val chooserIntent = shadowOf(RuntimeEnvironment.getApplication()).nextStartedActivity
|
||||
assertNotNull("Dialog was not displayed", chooserIntent)
|
||||
assertEquals(Intent.ACTION_CHOOSER, chooserIntent.action)
|
||||
assertEquals(dialogTitle, chooserIntent.extras?.getString(Intent.EXTRA_TITLE))
|
||||
assertThat(chooserIntent).isNotNull()
|
||||
assertThat(chooserIntent.action).isEqualTo(Intent.ACTION_CHOOSER)
|
||||
assertThat(chooserIntent.extras?.getString(Intent.EXTRA_TITLE)).isEqualTo(dialogTitle)
|
||||
|
||||
val contentIntent = chooserIntent.extras?.getParcelable(Intent.EXTRA_INTENT, Intent::class.java)
|
||||
assertNotNull("Intent was not built correctly", contentIntent)
|
||||
assertEquals(Intent.ACTION_SEND, contentIntent?.action)
|
||||
assertEquals(title, contentIntent?.extras?.getString(Intent.EXTRA_SUBJECT))
|
||||
assertEquals(message, contentIntent?.extras?.getString(Intent.EXTRA_TEXT))
|
||||
assertThat(contentIntent).isNotNull()
|
||||
assertThat(contentIntent?.action).isEqualTo(Intent.ACTION_SEND)
|
||||
|
||||
assertEquals(1, promise.resolved)
|
||||
assertThat(contentIntent?.extras?.getString(Intent.EXTRA_SUBJECT)).isEqualTo(title)
|
||||
assertThat(contentIntent?.extras?.getString(Intent.EXTRA_TEXT)).isEqualTo(message)
|
||||
|
||||
assertThat(promise.resolved).isEqualTo(1)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,8 +78,8 @@ class ShareModuleTest {
|
||||
|
||||
shareModule.share(null, dialogTitle, promise)
|
||||
|
||||
assertEquals(1, promise.rejected)
|
||||
assertEquals(ShareModule.ERROR_INVALID_CONTENT, promise.errorCode)
|
||||
assertThat(promise.rejected).isEqualTo(1)
|
||||
assertThat(promise.errorCode).isEqualTo(ShareModule.ERROR_INVALID_CONTENT)
|
||||
}
|
||||
|
||||
internal class SimplePromise : Promise {
|
||||
|
||||
Reference in New Issue
Block a user