|
| 1 | +/* |
| 2 | + * Copyright (c) 2022 New Vector Ltd |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package im.vector.app.features.settings.devices.v2 |
| 18 | + |
| 19 | +import im.vector.app.test.fakes.FakeVectorPreferences |
| 20 | +import org.junit.Test |
| 21 | + |
| 22 | +class ToggleIpAddressVisibilityUseCaseTest { |
| 23 | + |
| 24 | + private val fakeVectorPreferences = FakeVectorPreferences() |
| 25 | + |
| 26 | + private val toggleIpAddressVisibilityUseCase = ToggleIpAddressVisibilityUseCase( |
| 27 | + vectorPreferences = fakeVectorPreferences.instance, |
| 28 | + ) |
| 29 | + |
| 30 | + @Test |
| 31 | + fun `given ip addresses are currently visible then then visibility is set as false`() { |
| 32 | + // Given |
| 33 | + fakeVectorPreferences.givenShowIpAddressInSessionManagerScreens(true) |
| 34 | + |
| 35 | + // When |
| 36 | + toggleIpAddressVisibilityUseCase.execute() |
| 37 | + |
| 38 | + // Then |
| 39 | + fakeVectorPreferences.verifySetIpAddressVisibilityInDeviceManagerScreens(false) |
| 40 | + } |
| 41 | + |
| 42 | + @Test |
| 43 | + fun `given ip addresses are currently not visible then then visibility is set as true`() { |
| 44 | +// Given |
| 45 | + fakeVectorPreferences.givenShowIpAddressInSessionManagerScreens(false) |
| 46 | + |
| 47 | + // When |
| 48 | + toggleIpAddressVisibilityUseCase.execute() |
| 49 | + |
| 50 | + // Then |
| 51 | + fakeVectorPreferences.verifySetIpAddressVisibilityInDeviceManagerScreens(true) |
| 52 | + } |
| 53 | +} |
0 commit comments