generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test coverage to extension class
- Loading branch information
1 parent
883fbcd
commit 794204b
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
app/src/test/java/com/bitwarden/authenticator/data/platform/util/IntentExtensionsTest.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,52 @@ | ||
package com.bitwarden.authenticator.data.platform.util | ||
|
||
import android.content.Intent | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import org.junit.jupiter.api.Assertions.assertFalse | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import org.junit.jupiter.api.Test | ||
|
||
class IntentExtensionsTest { | ||
@Test | ||
fun `isSuspicious should return true when extras are not empty`() { | ||
val intent = mockk<Intent> { | ||
every { data } returns mockk() | ||
every { extras } returns mockk { | ||
every { isEmpty } returns false | ||
} | ||
} | ||
|
||
assertTrue(intent.isSuspicious) | ||
} | ||
|
||
@Test | ||
fun `isSuspicious should return true when extras are null`() { | ||
val intent = mockk<Intent> { | ||
every { data } returns mockk() | ||
every { extras } returns null | ||
} | ||
|
||
assertTrue(intent.isSuspicious) | ||
} | ||
|
||
@Test | ||
fun `isSuspicious should return true when data is not null`() { | ||
val intent = mockk<Intent> { | ||
every { data } returns mockk() | ||
every { extras } returns null | ||
} | ||
|
||
assertTrue(intent.isSuspicious) | ||
} | ||
|
||
@Test | ||
fun `isSuspicious should return false when data and extras are null`() { | ||
val intent = mockk<Intent> { | ||
every { data } returns null | ||
every { extras } returns null | ||
} | ||
|
||
assertFalse(intent.isSuspicious) | ||
} | ||
} |