Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,49 @@ describe('ActivityManagement Selectors', () => {
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' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ 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');
Expand All @@ -124,6 +135,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();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,60 @@ describe('EntryFieldsComponent', () => {
type: ActivityManagementActionTypes.LOAD_ACTIVITIES_SUCCESS,
payload: [],
};

actionSubject.next(action);

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');

Expand Down