This repository has been archived by the owner on May 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1137 from 47deg/am-test-navigationJobs-collections
Test navigation jobs collections
- Loading branch information
Showing
2 changed files
with
147 additions
and
4 deletions.
There are no files selected for viewing
143 changes: 143 additions & 0 deletions
143
...s/app/src/test/scala/cards/nine/app/ui/collections/jobs/NavigationJobsSpecification.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
package cards.nine.app.ui.collections.jobs | ||
|
||
import android.os.Bundle | ||
import cards.nine.app.ui.collections.jobs.uiactions.{GroupCollectionsDOM, GroupCollectionsUiActions, NavigationUiActions} | ||
import cards.nine.commons.test.TaskServiceSpecification | ||
import cards.nine.commons.test.data.CollectionTestData | ||
import macroid.ActivityContextWrapper | ||
import org.specs2.mock.Mockito | ||
import org.specs2.specification.Scope | ||
|
||
|
||
trait NavigationJobsSpecification extends TaskServiceSpecification | ||
with Mockito | ||
with CollectionTestData { | ||
|
||
|
||
trait NavigationJobsScope | ||
extends Scope { | ||
|
||
implicit val contextWrapper = mock[ActivityContextWrapper] | ||
|
||
implicit val mockGroupCollectionsJobs = mock[GroupCollectionsJobs] | ||
|
||
implicit val mockSingleCollectionJobs = mock[SingleCollectionJobs] | ||
|
||
val mockGroupCollectionsDOM = mock[GroupCollectionsDOM] | ||
|
||
val mockGroupCollectionsUiActions = mock[GroupCollectionsUiActions] | ||
|
||
val mockNavigationUiActions = mock[NavigationUiActions] | ||
|
||
mockNavigationUiActions.dom returns mockGroupCollectionsDOM | ||
|
||
val mockBundle = mock[Bundle] | ||
|
||
val navigationJobs = new NavigationJobs(mockGroupCollectionsUiActions, mockNavigationUiActions)(contextWrapper) | ||
|
||
} | ||
} | ||
|
||
class NavigationJobsSpec | ||
extends NavigationJobsSpecification { | ||
|
||
"showAppDialog" should { | ||
"call to openApps" in new NavigationJobsScope { | ||
|
||
mockGroupCollectionsDOM.getCurrentCollection returns Option(collection) | ||
mockNavigationUiActions.openApps(any)(any, any) returns serviceRight(Unit) | ||
|
||
navigationJobs.showAppDialog()(mockGroupCollectionsJobs, Option(mockSingleCollectionJobs)).mustRightUnit | ||
|
||
there was two(mockGroupCollectionsDOM).getCurrentCollection | ||
there was one(mockNavigationUiActions).openApps(any)(===(mockGroupCollectionsJobs), ===(Option(mockSingleCollectionJobs))) | ||
} | ||
|
||
"call to openApps when current collection is None" in new NavigationJobsScope { | ||
|
||
mockGroupCollectionsDOM.getCurrentCollection returns None | ||
mockNavigationUiActions.openApps(any)(any, any) returns serviceRight(Unit) | ||
|
||
navigationJobs.showAppDialog()(mockGroupCollectionsJobs, Option(mockSingleCollectionJobs)).mustRightUnit | ||
|
||
there was two(mockGroupCollectionsDOM).getCurrentCollection | ||
there was one(mockNavigationUiActions).openApps(any)(===(mockGroupCollectionsJobs), ===(Option(mockSingleCollectionJobs))) | ||
} | ||
} | ||
|
||
"showRecommendationDialog" should { | ||
|
||
"call to openRecommendations" in new NavigationJobsScope { | ||
|
||
mockGroupCollectionsDOM.getCurrentCollection returns Option(collection) | ||
mockNavigationUiActions.openRecommendations(any)(any, any) returns serviceRight(Unit) | ||
|
||
navigationJobs.showRecommendationDialog()(mockGroupCollectionsJobs, Option(mockSingleCollectionJobs)).mustRightUnit | ||
|
||
there was two(mockGroupCollectionsDOM).getCurrentCollection | ||
there was one(mockNavigationUiActions).openRecommendations(any)(===(mockGroupCollectionsJobs), ===(Option(mockSingleCollectionJobs))) | ||
} | ||
|
||
"shows a message of ContactUsError when current collection doesn't have appCategory and their cards doesn't have packageName" in new NavigationJobsScope { | ||
|
||
mockGroupCollectionsDOM.getCurrentCollection returns Option(collection.copy(appsCategory = None, cards = collection.cards.map (_.copy(packageName = None)))) | ||
mockGroupCollectionsUiActions.showContactUsError() returns serviceRight(Unit) | ||
|
||
navigationJobs.showRecommendationDialog()(mockGroupCollectionsJobs, Option(mockSingleCollectionJobs)).mustRightUnit | ||
|
||
there was one(mockGroupCollectionsDOM).getCurrentCollection | ||
there was one(mockGroupCollectionsUiActions).showContactUsError() | ||
} | ||
|
||
"shows a message of ContactUsError when current collection is None" in new NavigationJobsScope { | ||
|
||
mockGroupCollectionsDOM.getCurrentCollection returns None | ||
mockGroupCollectionsUiActions.showContactUsError() returns serviceRight(Unit) | ||
|
||
navigationJobs.showRecommendationDialog()(mockGroupCollectionsJobs, Option(mockSingleCollectionJobs)).mustRightUnit | ||
|
||
there was one(mockGroupCollectionsDOM).getCurrentCollection | ||
there was one(mockGroupCollectionsUiActions).showContactUsError() | ||
} | ||
} | ||
|
||
"showContactsDialog" should { | ||
"call to openContacts" in new NavigationJobsScope { | ||
|
||
mockNavigationUiActions.openContacts(any)(any, any) returns serviceRight(Unit) | ||
mockGroupCollectionsDOM.getCurrentCollection returns Option(collection) | ||
|
||
navigationJobs.showContactsDialog()(mockGroupCollectionsJobs, Option(mockSingleCollectionJobs)).mustRightUnit | ||
there was one(mockNavigationUiActions).openContacts(any)(===(mockGroupCollectionsJobs), ===(Option(mockSingleCollectionJobs))) | ||
} | ||
|
||
"call to openContacts when current collection is None" in new NavigationJobsScope { | ||
|
||
mockNavigationUiActions.openContacts(any)(any, any) returns serviceRight(Unit) | ||
mockGroupCollectionsDOM.getCurrentCollection returns None | ||
|
||
navigationJobs.showContactsDialog()(mockGroupCollectionsJobs, Option(mockSingleCollectionJobs)).mustRightUnit | ||
there was one(mockNavigationUiActions).openContacts(any)(===(mockGroupCollectionsJobs), ===(Option(mockSingleCollectionJobs))) | ||
} | ||
} | ||
|
||
"showShortcutDialog" should { | ||
"call to openShortcuts" in new NavigationJobsScope { | ||
|
||
mockNavigationUiActions.openShortcuts(any)(any, any) returns serviceRight(Unit) | ||
mockGroupCollectionsDOM.getCurrentCollection returns Option(collection) | ||
|
||
navigationJobs.showShortcutDialog()(mockGroupCollectionsJobs, Option(mockSingleCollectionJobs)).mustRightUnit | ||
there was one(mockNavigationUiActions).openShortcuts(any)(===(mockGroupCollectionsJobs), ===(Option(mockSingleCollectionJobs))) | ||
} | ||
|
||
"call to openShortcuts when current collection is None" in new NavigationJobsScope { | ||
|
||
mockNavigationUiActions.openShortcuts(any)(any, any) returns serviceRight(Unit) | ||
mockGroupCollectionsDOM.getCurrentCollection returns None | ||
|
||
navigationJobs.showShortcutDialog()(mockGroupCollectionsJobs, Option(mockSingleCollectionJobs)).mustRightUnit | ||
there was one(mockNavigationUiActions).openShortcuts(any)(===(mockGroupCollectionsJobs), ===(Option(mockSingleCollectionJobs))) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters