Skip to content

Commit

Permalink
ImageResizeModeTest.java => ImageResizeModeTest.kt (#38844)
Browse files Browse the repository at this point in the history
Summary:
This PR converts ImageResizeModeTest into Kotlin as requested in #38825 .

## Changelog:

[INTERNAL] [CHANGED] - Convert  to ImageResizeModeTest Kotlin

Pull Request resolved: #38844

Test Plan:
1. Run `./gradlew :packages:react-native:ReactAndroid:test`.
2. All tests should pass.

Reviewed By: rshest

Differential Revision: D48154896

Pulled By: cortinico

fbshipit-source-id: df131a4f3f9190af8d7b77e625e050f02824ad07
  • Loading branch information
atlj authored and facebook-github-bot committed Aug 8, 2023
1 parent 3660b7c commit 639b489
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 44 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.views.image

import com.facebook.drawee.drawable.ScalingUtils
import org.assertj.core.api.Assertions
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.powermock.core.classloader.annotations.PowerMockIgnore
import org.powermock.modules.junit4.rule.PowerMockRule
import org.robolectric.RobolectricTestRunner

@RunWith(RobolectricTestRunner::class)
@PowerMockIgnore("org.mockito.*", "org.robolectric.*", "androidx.*", "android.*")
class ImageResizeModeTest {
@get:Rule var rule = PowerMockRule()

@Test
fun testImageResizeMode() {
Assertions.assertThat(ImageResizeMode.toScaleType(null))
.isEqualTo(ScalingUtils.ScaleType.CENTER_CROP)
Assertions.assertThat(ImageResizeMode.toScaleType("contain"))
.isEqualTo(ScalingUtils.ScaleType.FIT_CENTER)
Assertions.assertThat(ImageResizeMode.toScaleType("cover"))
.isEqualTo(ScalingUtils.ScaleType.CENTER_CROP)
Assertions.assertThat(ImageResizeMode.toScaleType("stretch"))
.isEqualTo(ScalingUtils.ScaleType.FIT_XY)
Assertions.assertThat(ImageResizeMode.toScaleType("center"))
.isEqualTo(ScalingUtils.ScaleType.CENTER_INSIDE)

// No resizeMode set
Assertions.assertThat(ImageResizeMode.defaultValue())
.isEqualTo(ScalingUtils.ScaleType.CENTER_CROP)
}
}

0 comments on commit 639b489

Please sign in to comment.