1
- import { StopTimeEntryRunning } from './../store/entry.actions' ;
1
+ import { EntryActionTypes , StopTimeEntryRunning } from './../store/entry.actions' ;
2
2
import { async , ComponentFixture , TestBed , inject } from '@angular/core/testing' ;
3
3
import { HttpClientTestingModule } from '@angular/common/http/testing' ;
4
4
import { provideMockStore , MockStore } from '@ngrx/store/testing' ;
@@ -9,13 +9,15 @@ import { ProjectListHoverComponent } from '../components';
9
9
import { ProjectService } from '../../customer-management/components/projects/components/services/project.service' ;
10
10
import { FilterProjectPipe } from '../../shared/pipes' ;
11
11
import { AzureAdB2CService } from '../../login/services/azure.ad.b2c.service' ;
12
+ import { ActionsSubject } from '@ngrx/store' ;
12
13
13
14
describe ( 'TimeClockComponent' , ( ) => {
14
15
let component : TimeClockComponent ;
15
16
let fixture : ComponentFixture < TimeClockComponent > ;
16
17
let store : MockStore < ProjectState > ;
17
18
let projectService : ProjectService ;
18
19
let azureAdB2CService : AzureAdB2CService ;
20
+ const actionSub : ActionsSubject = new ActionsSubject ( ) ;
19
21
const state = {
20
22
projects : {
21
23
projects : [ { id : 'id' , name : 'name' , project_type_id : '' } ] ,
@@ -44,7 +46,10 @@ describe('TimeClockComponent', () => {
44
46
TestBed . configureTestingModule ( {
45
47
imports : [ HttpClientTestingModule ] ,
46
48
declarations : [ TimeClockComponent , ProjectListHoverComponent , FilterProjectPipe ] ,
47
- providers : [ ProjectService , AzureAdB2CService , provideMockStore ( { initialState : state } ) ] ,
49
+ providers : [ ProjectService ,
50
+ AzureAdB2CService ,
51
+ { provide : ActionsSubject , useValue : actionSub } ,
52
+ provideMockStore ( { initialState : state } ) ] ,
48
53
} ) . compileComponents ( ) ;
49
54
store = TestBed . inject ( MockStore ) ;
50
55
} ) ) ;
@@ -92,4 +97,22 @@ describe('TimeClockComponent', () => {
92
97
expect ( store . dispatch ) . toHaveBeenCalledWith ( new StopTimeEntryRunning ( 'id' ) ) ;
93
98
} ) ;
94
99
100
+ it ( 'on success create entry, the notification is shown' , ( ) => {
101
+ const actionSubject = TestBed . get ( ActionsSubject ) as ActionsSubject ;
102
+ const action = {
103
+ type : EntryActionTypes . CREATE_ENTRY_SUCCESS
104
+ } ;
105
+ actionSubject . next ( action ) ;
106
+ expect ( component . showNotification ) . toEqual ( true ) ;
107
+ } ) ;
108
+
109
+ it ( 'on success stop entry, the notification is shown' , ( ) => {
110
+ const actionSubject = TestBed . get ( ActionsSubject ) as ActionsSubject ;
111
+ const action = {
112
+ type : EntryActionTypes . STOP_TIME_ENTRY_RUNNING_SUCCESS
113
+ } ;
114
+ actionSubject . next ( action ) ;
115
+ expect ( component . showNotification ) . toEqual ( true ) ;
116
+ } ) ;
117
+
95
118
} ) ;
0 commit comments