Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Commit

Permalink
Improve test infra, add FormTest
Browse files Browse the repository at this point in the history
  • Loading branch information
afollestad committed Jan 14, 2019
1 parent 9a2ec3c commit 6fa0bb4
Show file tree
Hide file tree
Showing 12 changed files with 587 additions and 204 deletions.
3 changes: 3 additions & 0 deletions library/src/main/java/com/afollestad/vvalidator/form/Form.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class Form internal constructor(
fields.add(field)
}

/** Retrieves fields that have been added to the form. */
fun getFields(): List<FormField<*, *>> = fields

/** Adds an input field, which must be a [android.widget.EditText]. */
fun input(
@IdRes id: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package com.afollestad.vvalidator.assertion

import android.widget.CompoundButton
import com.afollestad.vvalidator.assertion.CompoundButtonAssertions.CheckedStateAssertion
import com.afollestad.vvalidator.testutil.isEqualTo
import com.afollestad.vvalidator.testutil.isFalse
import com.afollestad.vvalidator.testutil.isTrue
import com.afollestad.vvalidator.testutil.assertEqualTo
import com.afollestad.vvalidator.testutil.assertFalse
import com.afollestad.vvalidator.testutil.assertTrue
import com.nhaarman.mockitokotlin2.doReturn
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
Expand All @@ -34,26 +34,26 @@ class CompoundButtonAssertionTest {

whenever(view.isChecked).doReturn(false)
assertion.isValid(view)
.isFalse()
.assertFalse()
assertion.description()
.isEqualTo("should be checked")
.assertEqualTo("should be checked")

whenever(view.isChecked).doReturn(true)
assertion.isValid(view)
.isTrue()
.assertTrue()
}

@Test fun assertNotChecked() {
val assertion = CheckedStateAssertion(false)

whenever(view.isChecked).doReturn(false)
assertion.isValid(view)
.isTrue()
.assertTrue()

whenever(view.isChecked).doReturn(true)
assertion.isValid(view)
.isFalse()
.assertFalse()
assertion.description()
.isEqualTo("should not be checked")
.assertEqualTo("should not be checked")
}
}
Loading

0 comments on commit 6fa0bb4

Please sign in to comment.