BackgroundSyncChoiceTest.kt

1.7 KB · raw

1package com.peachpasswords.ui.pairing23import org.junit.Assert.assertEquals4import org.junit.Assert.assertFalse5import org.junit.Assert.assertTrue6import org.junit.Test78class BackgroundSyncChoiceTest {9    @Test fun `successful pairing prompts before navigation`() {10        assertTrue(shouldPromptForBackgroundSync(pairingSucceeded = true))11        assertFalse(shouldPromptForBackgroundSync(pairingSucceeded = false))12    }1314    @Test fun `back uses the recommended background default when notification is available`() {15        assertEquals(16            true,17            backgroundSyncChoice(18                BackgroundSyncAction.DISMISS,19                notificationsAvailable = true,20            ),21        )22    }2324    @Test fun `secondary action selects manual sync`() {25        assertEquals(26            false,27            backgroundSyncChoice(28                BackgroundSyncAction.MANUAL_ONLY,29                notificationsAvailable = true,30            ),31        )32    }3334    @Test fun `primary action selects background sync only with a visible notification`() {35        assertEquals(36            true,37            backgroundSyncChoice(38                BackgroundSyncAction.ALLOW,39                notificationsAvailable = true,40            ),41        )42        assertEquals(43            false,44            backgroundSyncChoice(45                BackgroundSyncAction.ALLOW,46                notificationsAvailable = false,47            ),48        )49    }5051    @Test fun `dismissal cannot silently enable background sync without notifications`() {52        assertEquals(53            false,54            backgroundSyncChoice(55                BackgroundSyncAction.DISMISS,56                notificationsAvailable = false,57            ),58        )59    }60}