diff --git a/src/app/modules/activities-management/pages/activities-management.component.html b/src/app/modules/activities-management/pages/activities-management.component.html index cdaaf85fb..51c431369 100644 --- a/src/app/modules/activities-management/pages/activities-management.component.html +++ b/src/app/modules/activities-management/pages/activities-management.component.html @@ -5,6 +5,7 @@ (changeValueShowActivityForm)="showActivityForm = $event" > + { expect(selectors.allActivities.projector(activityState)).toBe(activities); }); + it('should return all the ordered data in the state when the selector allAtiveActivities is called', () => { + const activities = [ + { + id: '001', + name: 'Meeting', + description: 'Some description' + }, + { + id: '002', + name: 'ABC', + description: 'Some description' + }, + { + id: '003', + name: 'XYZ', + description: 'Some description' + }, + ]; + + const activitiesOrdered = [ + { + id: '002', + name: 'ABC', + description: 'Some description' + }, + { + id: '001', + name: 'Meeting', + description: 'Some description' + }, + { + id: '003', + name: 'XYZ', + description: 'Some description' + }, + ]; + + const activityState = { data: activities }; + + expect(selectors.allActiveActivities.projector(activityState)).toEqual(activitiesOrdered); + + }); + it('should return all active data in the state when the selector allActiveActivities is called', () => { const activities = [{ id: 'id', name: 'abc', description: 'xxx', status: 'active' }, { id: '2', name: 'xyz', description: 'yyy', status: 'inactive' }, diff --git a/src/app/modules/reports/components/time-range-form/time-range.component.spec.ts b/src/app/modules/reports/components/time-range-form/time-range.component.spec.ts index a8d6bf66f..8fab76e79 100644 --- a/src/app/modules/reports/components/time-range-form/time-range.component.spec.ts +++ b/src/app/modules/reports/components/time-range-form/time-range.component.spec.ts @@ -115,6 +115,16 @@ describe('Reports Page', () => { expect(component.onSubmit).toHaveBeenCalled(); }); + it('triggers onSubmit with the form status valid', () => { + const valid = component.reportForm.valid; + spyOn(component, 'onSubmit'); + + component.setInitialDataOnScreen(); + + expect(valid).toBeTruthy(); + expect(component.onSubmit).toHaveBeenCalled(); + }); + it('When the ngOnChanges method is called, the onSubmit method is called', () => { const userId = 'abcd'; spyOn(component, 'onSubmit'); @@ -124,6 +134,15 @@ describe('Reports Page', () => { expect(component.onSubmit).toHaveBeenCalled(); }); + it('When the ngOnChanges method is the first change, the onSubmit method is not called', () => { + const userId = 'abcd'; + spyOn(component, 'onSubmit'); + + component.ngOnChanges({userId: new SimpleChange(null, userId, true)}); + + expect(component.onSubmit).not.toHaveBeenCalled(); + }); + afterEach(() => { fixture.destroy(); }); diff --git a/src/app/modules/shared/formatters/parse-date-time-offset/parse-date-time-offset.spec.ts b/src/app/modules/shared/formatters/parse-date-time-offset/parse-date-time-offset.spec.ts index d5c6ebb70..fae43cb1d 100644 --- a/src/app/modules/shared/formatters/parse-date-time-offset/parse-date-time-offset.spec.ts +++ b/src/app/modules/shared/formatters/parse-date-time-offset/parse-date-time-offset.spec.ts @@ -20,4 +20,31 @@ describe('ParseDateToUtcComponent', () => { expect(parseTimeOffset.parseDateTimeOffset(date, timezoneOffset)).toEqual(dateOffset); }); + it('returns "In progress" text when the date value is null', () => { + const parseTimeOffset = new ParseDateTimeOffset(); + const date = null; + const timezoneOffset = 420; + const dateOffset = '09:30'; + + expect(parseTimeOffset.parseDateTimeOffset(date, timezoneOffset)).toEqual('In progress'); + }); + + it('returns "In progress" text when the date value is undefined', () => { + const parseTimeOffset = new ParseDateTimeOffset(); + const date = undefined; + const timezoneOffset = 420; + const dateOffset = '09:30'; + + expect(parseTimeOffset.parseDateTimeOffset(date, timezoneOffset)).toEqual('In progress'); + }); + + it('returns "In progress" text when the date value is empty', () => { + const parseTimeOffset = new ParseDateTimeOffset(); + const date = ''; + const timezoneOffset = 420; + const dateOffset = '09:30'; + + expect(parseTimeOffset.parseDateTimeOffset(date, timezoneOffset)).toEqual('In progress'); + }); + }); diff --git a/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts b/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts index 37b3fb074..978d5bb42 100644 --- a/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts +++ b/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts @@ -361,6 +361,54 @@ describe('EntryFieldsComponent', () => { expect(component.activities).toEqual(action.payload); }); + it('activites are ordered using the payload of the action', () => { + const activities = [ + { + id: '004', + name: 'Meeting', + description: 'Some description' + }, + { + id: '005', + name: 'ABCD', + description: 'Some description' + }, + { + id: '006', + name: 'XYZA', + description: 'Some description' + }, + ]; + + const activitiesOrdered = [ + { + id: '005', + name: 'ABCD', + description: 'Some description' + }, + { + id: '004', + name: 'Meeting', + description: 'Some description' + }, + { + id: '006', + name: 'XYZA', + description: 'Some description' + }, + ]; + + const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject; + const action = { + type: ActivityManagementActionTypes.LOAD_ACTIVITIES_SUCCESS, + payload: activities, + }; + + actionSubject.next(action); + + expect(component.activities).toEqual(activitiesOrdered); + }); + it('LoadActiveEntry is dispatchen after LOAD_ACTIVITIES_SUCCESS', () => { spyOn(store, 'dispatch');