Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -11,6 +11,7 @@ import {
allActivities,
ResetActivityToEdit,
} from '../../store';
import { getActivityById } from '../../store/activity-management.selectors';
import { Activity } from 'src/app/modules/shared/models';

describe('CreateActivityComponent', () => {
Expand All @@ -20,6 +21,7 @@ describe('CreateActivityComponent', () => {
let activityIdtoEditMock;
let allActivitiesMock;
let getActivityByIdMock;
let getActivityByIdSelectorMock;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yo can use the variable getActivityByIdMock that is to mock that selector, you don't need to create getActivityByIdSelectorMock


const state = {
data: [{ id: '', name: '', description: '' }],
Expand Down Expand Up @@ -58,6 +60,12 @@ describe('CreateActivityComponent', () => {
expect(component).toBeTruthy();
});

it('onInit, LoadActivitys action is despatched', () => {
getActivityByIdSelectorMock = store.overrideSelector(getActivityById, activity);
component.ngOnInit();
expect(component.activityToEdit).toEqual(activity);
});

it('should reset form onSubmit and dispatch UpdateActivity action', () => {
const currentState = {
data: [{ id: '1', name: 'xxx', description: 'xxxx' }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
projectTypeIdToEdit,
allProjectTypes,
ResetProjectTypeToEdit,
getProjectTypeById,
} from '../../store';
import { ProjectType } from '../../../../../shared/models/project-type.model';

Expand All @@ -20,6 +21,7 @@ describe('InputProjectTypeComponent', () => {
let projectTypeIdToEditMock;
let allProjectTypesMock;
let getProjectTypeByIdMock;
let getProjectTypeByIdSelectorMock;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tha same case. you can use getProjectTypeByIdMock and not create a new variable.


const state = {
data: [{ id: '', name: '', description: '' }],
Expand All @@ -45,7 +47,6 @@ describe('InputProjectTypeComponent', () => {
fixture = TestBed.createComponent(CreateProjectTypeComponent);
component = fixture.componentInstance;
fixture.detectChanges();

store = TestBed.inject(MockStore);
store.setState(state);
});
Expand All @@ -58,6 +59,13 @@ describe('InputProjectTypeComponent', () => {
expect(component).toBeTruthy();
});

it('onInit, LoadProjectsType action is dispatched', () => {
getProjectTypeByIdSelectorMock = store.overrideSelector(getProjectTypeById, projectType);
component.ngOnInit();

expect(component.projectTypeToEdit).toEqual(projectType);
});

it('should reset form onSubmit and dispatch UpdateProjectType action', () => {
const currentState = {
data: [{ id: '1', name: 'xxx', description: 'xxxx' }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('ProjectListComponent', () => {

store = TestBed.inject(MockStore);
store.setState(state);
allProjectsSelectorMock = store.overrideSelector(allProjects, state.projectToEdit);
allProjectsSelectorMock = store.overrideSelector(allProjects, state);
component.projectsSubscription = new Subscription();
});

Expand Down