Skip to content

Commit 306aa9e

Browse files
committed
#62 renaming tests and removing not needed service injection
1 parent 989a125 commit 306aa9e

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/app/modules/project-management/components/create-project/create-project.component.spec.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,58 +42,63 @@ describe('CreateProjectComponent', () => {
4242
name: 'Project Test 13',
4343
description: 'description',
4444
};
45-
4645
component.projectToEdit = newData;
46+
4747
component.ngOnChanges();
48+
4849
expect(component.projectForm.value.name).toEqual(newData.name);
4950
expect(component.projectForm.value.description).toEqual(newData.description);
5051
expect(component.isUpdating).toEqual(true);
5152
});
5253

53-
it('should emit ngOnChange and reset ProjectForm', () => {
54+
it('on ngOnChange with projectToEdit=null should reset projectForm', () => {
5455
component.projectToEdit = null;
56+
5557
component.ngOnChanges();
5658

5759
expect(component.projectForm.value.name).toEqual(null);
5860
expect(component.projectForm.value.description).toEqual(null);
5961
expect(component.isUpdating).toEqual(false);
6062
});
6163

62-
it('should dispatch CreateProject action #onSubmit', () => {
64+
it('should dispatch CreateProject action #onSubmit if isUpdating=false', () => {
6365
const project = {
6466
id: '1',
6567
name: 'app 4',
6668
description: 'It is a good app',
6769
};
68-
6970
component.isUpdating = false;
7071
spyOn(store, 'dispatch');
72+
7173
component.onSubmit(project);
74+
7275
expect(store.dispatch).toHaveBeenCalledWith(new actions.CreateProject(project));
7376
});
7477

75-
it('should dispatch UpdateProject action #onSubmit', () => {
78+
it('should dispatch UpdateProject action #onSubmit if isUpdating=true', () => {
7679
const project = {
7780
id: '1',
7881
name: 'app 4',
7982
description: 'It is a good app',
8083
};
81-
8284
component.isUpdating = true;
8385
spyOn(store, 'dispatch');
86+
8487
component.onSubmit(project);
88+
8589
expect(store.dispatch).toHaveBeenCalledWith(new actions.UpdateProject(project));
8690
});
8791

88-
it('should clean the form and send a cancelForm event #reset', () => {
92+
it('should clean the form and emmit a cancelForm event on #reset', () => {
8993
const project = {
9094
name: 'app 4',
9195
description: 'It is a good app',
9296
};
93-
9497
component.projectForm.setValue(project);
9598
spyOn(component.cancelForm, 'emit');
99+
96100
component.reset();
101+
97102
expect(component.projectForm.value.name).toEqual(null);
98103
expect(component.projectForm.value.description).toEqual(null);
99104
expect(component.cancelForm.emit).toHaveBeenCalled();

src/app/modules/project-management/store/project.effects.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { Injectable } from '@angular/core';
22
import { ofType, Actions, Effect } from '@ngrx/effects';
3-
import { Action, Store } from '@ngrx/store';
3+
import { Action } from '@ngrx/store';
44
import { of, Observable } from 'rxjs';
55
import { catchError, map, mergeMap } from 'rxjs/operators';
66
import { ProjectService } from '../services/project.service';
77
import * as actions from './project.actions';
88

99
@Injectable()
1010
export class ProjectEffects {
11-
constructor(private actions$: Actions, private projectService: ProjectService, private store: Store<any>) {}
11+
constructor(private actions$: Actions, private projectService: ProjectService) {}
1212

1313
@Effect()
1414
loadProjects$: Observable<Action> = this.actions$.pipe(

0 commit comments

Comments
 (0)