1- import { StopTimeEntryRunning } from './../store/entry.actions' ;
1+ import { EntryActionTypes , StopTimeEntryRunning } from './../store/entry.actions' ;
22import { async , ComponentFixture , TestBed , inject } from '@angular/core/testing' ;
33import { HttpClientTestingModule } from '@angular/common/http/testing' ;
44import { provideMockStore , MockStore } from '@ngrx/store/testing' ;
@@ -9,13 +9,15 @@ import { ProjectListHoverComponent } from '../components';
99import { ProjectService } from '../../customer-management/components/projects/components/services/project.service' ;
1010import { FilterProjectPipe } from '../../shared/pipes' ;
1111import { AzureAdB2CService } from '../../login/services/azure.ad.b2c.service' ;
12+ import { ActionsSubject } from '@ngrx/store' ;
1213
1314describe ( 'TimeClockComponent' , ( ) => {
1415 let component : TimeClockComponent ;
1516 let fixture : ComponentFixture < TimeClockComponent > ;
1617 let store : MockStore < ProjectState > ;
1718 let projectService : ProjectService ;
1819 let azureAdB2CService : AzureAdB2CService ;
20+ const actionSub : ActionsSubject = new ActionsSubject ( ) ;
1921 const state = {
2022 projects : {
2123 projects : [ { id : 'id' , name : 'name' , project_type_id : '' } ] ,
@@ -44,7 +46,10 @@ describe('TimeClockComponent', () => {
4446 TestBed . configureTestingModule ( {
4547 imports : [ HttpClientTestingModule ] ,
4648 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 } ) ] ,
4853 } ) . compileComponents ( ) ;
4954 store = TestBed . inject ( MockStore ) ;
5055 } ) ) ;
@@ -92,4 +97,22 @@ describe('TimeClockComponent', () => {
9297 expect ( store . dispatch ) . toHaveBeenCalledWith ( new StopTimeEntryRunning ( 'id' ) ) ;
9398 } ) ;
9499
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+
95118} ) ;
0 commit comments