Skip to content

Instantly share code, notes, and snippets.

@zsmb13
Last active June 29, 2022 12:13
Show Gist options
  • Save zsmb13/2c11c0b1200a17f7fad15e02831d4172 to your computer and use it in GitHub Desktop.
Save zsmb13/2c11c0b1200a17f7fad15e02831d4172 to your computer and use it in GitHub Desktop.
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Example with the old APIs
@Test
fun loadTasks_loading() {
// Pause dispatcher so we can verify initial values
mainCoroutineRule.pauseDispatcher()
// Load the task in the viewmodel
statisticsViewModel.refresh()
// Then progress indicator is shown
assertThat(statisticsViewModel.dataLoading.getOrAwaitValue()).isTrue()
// Execute pending coroutine actions
mainCoroutineRule.resumeDispatcher()
// Then progress indicator is hidden
assertThat(statisticsViewModel.dataLoading.getOrAwaitValue()).isFalse()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment