Skip to content

Commit

Permalink
Add test coverage to extension class
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintPatrck committed Jun 14, 2024
1 parent 883fbcd commit 794204b
Showing 1 changed file with 52 additions and 0 deletions.
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)
}
}

0 comments on commit 794204b

Please sign in to comment.