1
+ import { ToastrService , IndividualConfig } from 'ngx-toastr' ;
1
2
import { SwitchTimeEntry } from './../../store/entry.actions' ;
2
3
import { FormBuilder } from '@angular/forms' ;
3
4
import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
@@ -17,6 +18,9 @@ describe('ProjectListHoverComponent', () => {
17
18
let fixture : ComponentFixture < ProjectListHoverComponent > ;
18
19
let store : MockStore < ProjectState > ;
19
20
let mockProjectsSelector ;
21
+ const toastrServiceStub = {
22
+ error : ( message ?: string , title ?: string , override ?: Partial < IndividualConfig > ) => { }
23
+ } ;
20
24
21
25
const state = {
22
26
projects : {
@@ -41,7 +45,8 @@ describe('ProjectListHoverComponent', () => {
41
45
beforeEach ( async ( ( ) => {
42
46
TestBed . configureTestingModule ( {
43
47
declarations : [ ProjectListHoverComponent , FilterProjectPipe ] ,
44
- providers : [ FormBuilder , provideMockStore ( { initialState : state } ) ] ,
48
+ providers : [ FormBuilder , provideMockStore ( { initialState : state } ) ,
49
+ { provide : ToastrService , useValue : toastrServiceStub } ] ,
45
50
imports : [ HttpClientTestingModule , AutocompleteLibModule ] ,
46
51
} ) . compileComponents ( ) ;
47
52
store = TestBed . inject ( MockStore ) ;
@@ -76,6 +81,15 @@ describe('ProjectListHoverComponent', () => {
76
81
expect ( store . dispatch ) . toHaveBeenCalledWith ( new UpdateEntryRunning ( { id : component . activeEntry . id , project_id : 1 } ) ) ;
77
82
} ) ;
78
83
84
+ it ( 'displays a message when the acitivity_id is null' , ( ) => {
85
+ spyOn ( toastrServiceStub , 'error' ) ;
86
+ component . activeEntry = { activity_id : null } ;
87
+
88
+ component . switch ( 1 , 'customer' , 'project' ) ;
89
+
90
+ expect ( toastrServiceStub . error ) . toHaveBeenCalled ( ) ;
91
+ } ) ;
92
+
79
93
it ( 'dispatch a SwitchTimeEntry action' , ( ) => {
80
94
spyOn ( store , 'dispatch' ) ;
81
95
component . activeEntry = { id : '123' } ;
0 commit comments