Skip to content

Commit

Permalink
Set isValid = false in INITIAL_PIN_ELEMENT_STATE
Browse files Browse the repository at this point in the history
  • Loading branch information
devinmorgan committed Dec 5, 2023
1 parent a0d1c59 commit b51a4e8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class ElementStateManagerTest {
assertThat(state.isValid).isEqualTo(INITIAL_PIN_ELEMENT_STATE.isValid)
assertThat(state.isComplete).isEqualTo(INITIAL_PIN_ELEMENT_STATE.isComplete)
assertThat(state.validationError).isEqualTo(INITIAL_PIN_ELEMENT_STATE.validationError)
// TODO: Compiler is very confused about accessing the state.details for the PIN
// This test fails because of it
assertThat(state.details).isEqualTo(INITIAL_PIN_ELEMENT_STATE.details)
// cast to Any? to avoid ambiguous overload issue that
// is unique to PinDetails because it's an alias for `Nothing?`
assertThat(state.details as Any?).isEqualTo(INITIAL_PIN_ELEMENT_STATE.details)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.joinforage.forage.android.core.element.state

import org.assertj.core.api.Assertions.assertThat
import org.junit.Test

class ElementStateTest {

@Test
fun testInitialPinElementState() {
assertThat(INITIAL_PIN_ELEMENT_STATE.isFocused).isFalse
assertThat(INITIAL_PIN_ELEMENT_STATE.isBlurred).isTrue
assertThat(INITIAL_PIN_ELEMENT_STATE.isEmpty).isTrue
assertThat(INITIAL_PIN_ELEMENT_STATE.isValid).isFalse
assertThat(INITIAL_PIN_ELEMENT_STATE.isComplete).isFalse
assertThat(INITIAL_PIN_ELEMENT_STATE.validationError).isNull()

// cast to Any? to avoid ambiguous overload issue that
// is unique to PinDetails because it's an alias for `Nothing?`
assertThat(INITIAL_PIN_ELEMENT_STATE.details as Any?).isNull()
}

@Test
fun testInitialPanElementState() {
assertThat(INITIAL_PAN_ELEMENT_STATE.isFocused).isFalse
assertThat(INITIAL_PAN_ELEMENT_STATE.isBlurred).isTrue
assertThat(INITIAL_PAN_ELEMENT_STATE.isEmpty).isTrue
assertThat(INITIAL_PAN_ELEMENT_STATE.isValid).isTrue
assertThat(INITIAL_PAN_ELEMENT_STATE.isComplete).isFalse
assertThat(INITIAL_PAN_ELEMENT_STATE.validationError).isNull()
assertThat(INITIAL_PAN_ELEMENT_STATE.details).isEqualTo(PanDetails(DerivedCardInfo()))
}

}

0 comments on commit b51a4e8

Please sign in to comment.