Skip to content
This repository has been archived by the owner on May 8, 2019. It is now read-only.

Commit

Permalink
Added some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anamariamv committed Nov 21, 2016
1 parent f841476 commit 794a5db
Showing 1 changed file with 95 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package cards.nine.app.ui.collections.jobs

import cards.nine.app.di.Injector
import cards.nine.app.observers.ObserverRegister
import cards.nine.app.ui.collections.jobs.uiactions.{NavigationUiActions, ToolbarUiActions, GroupCollectionsUiActions, SingleCollectionUiActions}
import cards.nine.app.ui.launcher.jobs.LauncherTestData
import cards.nine.commons.test.TaskServiceSpecification
import cards.nine.commons.test.data.CollectionTestData
import cards.nine.process.collection.CollectionProcess
import cards.nine.process.theme.ThemeProcess
import cards.nine.process.trackevent.TrackEventProcess
import macroid.ActivityContextWrapper
import org.specs2.mock.Mockito
import org.specs2.specification.Scope

trait GroupCollectionsJobsSpecification extends TaskServiceSpecification
with Mockito {

trait GroupCollectionsJobsScope
extends Scope
with CollectionTestData
with LauncherTestData {

implicit val contextWrapper = mock[ActivityContextWrapper]

val mockInjector = mock[Injector]

val mockGroupCollectionsUiActions = mock[GroupCollectionsUiActions]

val mockNavigationUiActions = mock[NavigationUiActions]

val mockToolbarUiActions = mock[ToolbarUiActions]

val mockTrackEventProcess = mock[TrackEventProcess]

mockInjector.trackEventProcess returns mockTrackEventProcess

val mockCollectionProcess = mock[CollectionProcess]

mockInjector.collectionProcess returns mockCollectionProcess

val mockThemeProcess = mock[ThemeProcess]

mockInjector.themeProcess returns mockThemeProcess

val mockObserverRegister = mock[ObserverRegister]

mockInjector.observerRegister returns mockObserverRegister

val groupCollectionsJobs = new GroupCollectionsJobs(mockGroupCollectionsUiActions,mockToolbarUiActions,mockNavigationUiActions)(contextWrapper)

}

}


class GroupCollectionsJobsSpec
extends GroupCollectionsJobsSpecification {

"resume" should {
"calls to register Observer" in new GroupCollectionsJobsScope {

mockObserverRegister.registerObserverTask() returns serviceRight(Unit)
groupCollectionsJobs.resume().mustRightUnit
there was one(mockObserverRegister).registerObserverTask()
}
}

"pause" should {
"calls to unregister Observer" in new GroupCollectionsJobsScope {

mockObserverRegister.unregisterObserverTask() returns serviceRight(Unit)
groupCollectionsJobs.pause().mustRightUnit
there was one(mockObserverRegister).unregisterObserverTask()
}
}

"back" should {
"calls to back" in new GroupCollectionsJobsScope {

mockGroupCollectionsUiActions.back() returns serviceRight(Unit)
groupCollectionsJobs.back().mustRightUnit
there was one(mockGroupCollectionsUiActions).back()
}
}

"destroy" should {
"calls to destroy" in new GroupCollectionsJobsScope {

mockGroupCollectionsUiActions.destroy() returns serviceRight(Unit)
groupCollectionsJobs.destroy().mustRightUnit
there was one(mockGroupCollectionsUiActions).destroy()
}
}
}

0 comments on commit 794a5db

Please sign in to comment.