Implement "unviewed only" mode for story viewer.

This commit is contained in:
Alex Hart
2022-06-24 14:14:13 -03:00
committed by Cody Henthorne
parent 89a6730efe
commit 858c7a7f2e
13 changed files with 91 additions and 34 deletions

View File

@@ -35,7 +35,7 @@ class StoryViewerViewModelTest {
fun `Given a list of recipients, when I initialize, then I expect the list`() {
// GIVEN
val repoStories: List<RecipientId> = (1L..5L).map(RecipientId::from)
whenever(repository.getStories(any())).doReturn(Single.just(repoStories))
whenever(repository.getStories(any(), any())).doReturn(Single.just(repoStories))
val injectedStories: List<RecipientId> = (6L..10L).map(RecipientId::from)
@@ -51,7 +51,7 @@ class StoryViewerViewModelTest {
testScheduler.triggerActions()
// THEN
verify(repository, never()).getStories(any())
verify(repository, never()).getStories(any(), any())
assertEquals(injectedStories, testSubject.stateSnapshot.pages)
}
@@ -60,7 +60,7 @@ class StoryViewerViewModelTest {
// GIVEN
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
val startStory = RecipientId.from(2L)
whenever(repository.getStories(any())).doReturn(Single.just(stories))
whenever(repository.getStories(any(), any())).doReturn(Single.just(stories))
// WHEN
val testSubject = StoryViewerViewModel(
@@ -84,7 +84,7 @@ class StoryViewerViewModelTest {
// GIVEN
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
val startStory = RecipientId.from(1L)
whenever(repository.getStories(any())).doReturn(Single.just(stories))
whenever(repository.getStories(any(), any())).doReturn(Single.just(stories))
val testSubject = StoryViewerViewModel(
StoryViewerArgs(
recipientId = startStory,
@@ -110,7 +110,7 @@ class StoryViewerViewModelTest {
// GIVEN
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
val startStory = stories.last()
whenever(repository.getStories(any())).doReturn(Single.just(stories))
whenever(repository.getStories(any(), any())).doReturn(Single.just(stories))
val testSubject = StoryViewerViewModel(
StoryViewerArgs(
recipientId = startStory,
@@ -136,7 +136,7 @@ class StoryViewerViewModelTest {
// GIVEN
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
val startStory = stories.last()
whenever(repository.getStories(any())).doReturn(Single.just(stories))
whenever(repository.getStories(any(), any())).doReturn(Single.just(stories))
val testSubject = StoryViewerViewModel(
StoryViewerArgs(
recipientId = startStory,
@@ -162,7 +162,7 @@ class StoryViewerViewModelTest {
// GIVEN
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
val startStory = stories.first()
whenever(repository.getStories(any())).doReturn(Single.just(stories))
whenever(repository.getStories(any(), any())).doReturn(Single.just(stories))
val testSubject = StoryViewerViewModel(
StoryViewerArgs(
recipientId = startStory,
@@ -188,7 +188,7 @@ class StoryViewerViewModelTest {
// GIVEN
val stories: List<RecipientId> = (1L..5L).map(RecipientId::from)
val startStory = stories.first()
whenever(repository.getStories(any())).doReturn(Single.just(stories))
whenever(repository.getStories(any(), any())).doReturn(Single.just(stories))
val testSubject = StoryViewerViewModel(
StoryViewerArgs(
recipientId = startStory,

View File

@@ -42,7 +42,7 @@ class StoryViewerPageViewModelTest {
fun `Given first page and first post, when I goToPreviousPost, then I expect storyIndex to be 0`() {
// GIVEN
val storyPosts = createStoryPosts(3) { true }
whenever(repository.getStoryPostsFor(any())).thenReturn(Observable.just(storyPosts))
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
val testSubject = createTestSubject()
testSubject.setIsFirstPage(true)
testScheduler.triggerActions()
@@ -61,7 +61,7 @@ class StoryViewerPageViewModelTest {
fun `Given first page and second post, when I goToPreviousPost, then I expect storyIndex to be 0`() {
// GIVEN
val storyPosts = createStoryPosts(3) { true }
whenever(repository.getStoryPostsFor(any())).thenReturn(Observable.just(storyPosts))
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
val testSubject = createTestSubject()
testSubject.setIsFirstPage(true)
testScheduler.triggerActions()
@@ -82,7 +82,7 @@ class StoryViewerPageViewModelTest {
fun `Given no initial story and 3 records all viewed, when I initialize, then I expect storyIndex to be 0`() {
// GIVEN
val storyPosts = createStoryPosts(3) { true }
whenever(repository.getStoryPostsFor(any())).thenReturn(Observable.just(storyPosts))
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
// WHEN
val testSubject = createTestSubject()
@@ -98,7 +98,7 @@ class StoryViewerPageViewModelTest {
fun `Given no initial story and 3 records all not viewed, when I initialize, then I expect storyIndex to be 0`() {
// GIVEN
val storyPosts = createStoryPosts(3) { false }
whenever(repository.getStoryPostsFor(any())).thenReturn(Observable.just(storyPosts))
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
// WHEN
val testSubject = createTestSubject()
@@ -114,7 +114,7 @@ class StoryViewerPageViewModelTest {
fun `Given no initial story and 3 records with 2nd is not viewed, when I initialize, then I expect storyIndex to be 1`() {
// GIVEN
val storyPosts = createStoryPosts(3) { it % 2 != 0 }
whenever(repository.getStoryPostsFor(any())).thenReturn(Observable.just(storyPosts))
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
// WHEN
val testSubject = createTestSubject()
@@ -130,7 +130,7 @@ class StoryViewerPageViewModelTest {
fun `Given no initial story and 3 records with 1st and 3rd not viewed, when I goToNext, then I expect storyIndex to be 2`() {
// GIVEN
val storyPosts = createStoryPosts(3) { it % 2 == 0 }
whenever(repository.getStoryPostsFor(any())).thenReturn(Observable.just(storyPosts))
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
// WHEN
val testSubject = createTestSubject()
@@ -148,7 +148,7 @@ class StoryViewerPageViewModelTest {
fun `Given a single story, when I goToPrevious, then I expect storyIndex to be -1`() {
// GIVEN
val storyPosts = createStoryPosts(1)
whenever(repository.getStoryPostsFor(any())).thenReturn(Observable.just(storyPosts))
whenever(repository.getStoryPostsFor(any(), any())).thenReturn(Observable.just(storyPosts))
// WHEN
val testSubject = createTestSubject()
@@ -166,6 +166,7 @@ class StoryViewerPageViewModelTest {
return StoryViewerPageViewModel(
RecipientId.from(1),
-1L,
false,
repository
)
}