Skip to content

Commit a69a911

Browse files
committed
fix: #29 Fix comments
1 parent f482065 commit a69a911

13 files changed

+69
-60
lines changed

scripts/populate-keys.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
echo 'export const AUTHORITY = "'$AUTHORITY'";' >> src/environments/keys.ts
55
echo 'export const CLIENT_ID = "'$CLIENT_ID'";' >> src/environments/keys.ts
66
echo 'export const SCOPES = ["'$SCOPES'"];' >> src/environments/keys.ts
7-
echo 'export const STACK_EXCHANGE_ID = ["'$STACK_EXCHANGE_ID'"];' >> src/environments/keys.ts
8-
echo 'export const STACK_EXCHANGE_ACCESS_TOKEN = ["'$STACK_EXCHANGE_ACCESS_TOKEN'"];' >> src/environments/keys.ts
7+
echo 'export const STACK_EXCHANGE_ID = "'$STACK_EXCHANGE_ID'";' >> src/environments/keys.ts
8+
echo 'export const STACK_EXCHANGE_ACCESS_TOKEN = "'$STACK_EXCHANGE_ACCESS_TOKEN'";' >> src/environments/keys.ts

src/app/modules/shared/components/details-fields/details-fields.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@
5252

5353
<app-search-project (changeFilterProject)="filterTechnology = $event"></app-search-project>
5454
<div *ngIf="isLoading">LOADING...</div>
55-
<div *ngIf="technologies" class="d-flex flex-column technology-content">
55+
<div *ngIf="technology" class="d-flex flex-column technology-content">
5656
<div
57-
*ngFor="let technology of technologies.items | filterProject: filterTechnology"
58-
(click)="setTechnology(technology.name)"
57+
*ngFor="let item of technology.items | filterProject: filterTechnology"
58+
(click)="setTechnology(item.name)"
5959
class="technology-list"
60-
[ngClass]="{ active: selectedTechnology.includes(technology.name) }"
60+
[ngClass]="{ active: selectedTechnology.includes(item.name) }"
6161
>
62-
{{ technology.name }}
62+
{{ item.name }}
6363
</div>
6464
</div>
6565
<div class="tags-content d-flex flex-wrap">

src/app/modules/shared/components/details-fields/details-fields.component.spec.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe('DetailsFieldsComponent', () => {
1313
let fixture: ComponentFixture<DetailsFieldsComponent>;
1414
let store: MockStore<TechnologyState>;
1515
let mockTechnologySelector;
16+
let length;
1617

1718
const state = {
1819
technologyList: { items: [{ name: 'java' }] },
@@ -53,12 +54,6 @@ describe('DetailsFieldsComponent', () => {
5354
expect(component).toBeTruthy();
5455
});
5556

56-
it('should emit saveEntry event', () => {
57-
spyOn(component.saveEntry, 'emit');
58-
component.onSubmit();
59-
expect(component.saveEntry.emit).toHaveBeenCalledWith(initialData);
60-
});
61-
6257
it('should emit ngOnChange without data', () => {
6358
component.entryToEdit = null;
6459
component.ngOnChanges();
@@ -71,12 +66,22 @@ describe('DetailsFieldsComponent', () => {
7166
expect(component.entryForm.value).toEqual(newData);
7267
});
7368

74-
it('should dispatch LoadTechnology action #getTechnologies', () => {
69+
it('should dispatch FindTechnology action #getTechnologies', () => {
7570
const value = 'java';
7671
spyOn(store, 'dispatch');
72+
length = value.length;
7773
component.getTechnologies(value);
7874

79-
expect(store.dispatch).toHaveBeenCalledWith(new actions.LoadTechnology(value));
75+
expect(store.dispatch).toHaveBeenCalledWith(new actions.FindTechnology(value));
76+
});
77+
78+
it('should NOT dispatch FindTechnology action #getTechnologies', () => {
79+
const value = 'j';
80+
spyOn(store, 'dispatch');
81+
length = value.length;
82+
component.getTechnologies(value);
83+
84+
expect(store.dispatch).not.toHaveBeenCalledWith(new actions.FindTechnology(value));
8085
});
8186

8287
it('should add a new tag #setTechnology', () => {
@@ -102,4 +107,10 @@ describe('DetailsFieldsComponent', () => {
102107
component.removeTag(index);
103108
expect(component.selectedTechnology.length).toBe(1);
104109
});
110+
111+
it('should emit saveEntry event', () => {
112+
spyOn(component.saveEntry, 'emit');
113+
component.onSubmit();
114+
expect(component.saveEntry.emit).toHaveBeenCalledWith(initialData);
115+
});
105116
});

src/app/modules/shared/components/details-fields/details-fields.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
1717
@Output() saveEntry = new EventEmitter();
1818
@ViewChild('closeModal') closeModal: ElementRef;
1919
entryForm: FormGroup;
20-
technologies: Technology;
20+
technology: Technology;
2121
filterTechnology = '';
2222
selectedTechnology: string[] = [];
2323
isLoading = false;
@@ -35,13 +35,13 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
3535
const technologies$ = this.store.pipe(select(allTechnologies));
3636
technologies$.subscribe((response) => {
3737
this.isLoading = response.isLoading;
38-
this.technologies = response.technologyList;
38+
this.technology = response.technologyList;
3939
});
4040
}
4141

4242
ngOnChanges(): void {
4343
if (this.entryToEdit) {
44-
this.selectedTechnology = this.entryToEdit.technology;
44+
this.selectedTechnology = this.entryToEdit.technologies;
4545

4646
this.entryForm.setValue({
4747
project: this.entryToEdit.project,
@@ -54,7 +54,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
5454

5555
getTechnologies(value) {
5656
if (value.length >= 2) {
57-
this.store.dispatch(new actions.LoadTechnology(value));
57+
this.store.dispatch(new actions.FindTechnology(value));
5858
}
5959
}
6060

src/app/modules/shared/components/modal/modal.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('ModalComponent', () => {
3333
startDate: '2020-02-05T15:36:15.887Z',
3434
endDate: '2020-02-05T18:36:15.887Z',
3535
activity: 'development',
36-
technology: ['Angular', 'TypeScript'],
36+
technologies: ['Angular', 'TypeScript'],
3737
};
3838

3939
spyOn(component.removeList, 'emit');

src/app/modules/shared/models/entry.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export interface Entry {
44
startDate: string;
55
endDate: string;
66
activity: string;
7-
technology: string[];
7+
technologies: string[];
88
comments?: string;
99
ticket?: string;
1010
}

src/app/modules/shared/store/technology.actions.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import * as actions from './technology.actions';
22
import { Technology } from '../models';
33

44
describe('Actions for Technology', () => {
5-
it('LoadTechnologySuccess type is TechnologyActionTypes.LOAD_TECHNOLOGY_SUCCESS', () => {
5+
it('FindTechnologySuccess type is TechnologyActionTypes.FIND_TECHNOLOGIES_SUCESS', () => {
66
const technologyList: Technology = { items: [{ name: 'java' }, { name: 'javascript' }] };
7-
const loadTechnologySuccess = new actions.LoadTechnologySuccess(technologyList);
8-
expect(loadTechnologySuccess.type).toEqual(actions.TechnologyActionTypes.LOAD_TECHNOLOGY_SUCCESS);
7+
const findTechnologySuccess = new actions.FindTechnologySuccess(technologyList);
8+
expect(findTechnologySuccess.type).toEqual(actions.TechnologyActionTypes.FIND_TECHNOLOGIES_SUCESS);
99
});
1010

11-
it('LoadTechnologyFail type is TechnologyActionTypes.LOAD_TECHNOLOGY_FAIL', () => {
12-
const loadTechnologyFail = new actions.LoadTechnologyFail('error');
13-
expect(loadTechnologyFail.type).toEqual(actions.TechnologyActionTypes.LOAD_TECHNOLOGY_FAIL);
11+
it('FindTechnologyFail type is TechnologyActionTypes.FIND_TECHNOLOGIES_FAIL', () => {
12+
const findTechnologyFail = new actions.FindTechnologyFail('error');
13+
expect(findTechnologyFail.type).toEqual(actions.TechnologyActionTypes.FIND_TECHNOLOGIES_FAIL);
1414
});
1515
});

src/app/modules/shared/store/technology.actions.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ import { Action } from '@ngrx/store';
22
import { Technology } from '../models/technology.model';
33

44
export enum TechnologyActionTypes {
5-
LOAD_TECHNOLOGY = '[Technology] LOAD_TECHNOLOGY',
6-
LOAD_TECHNOLOGY_SUCCESS = '[Technology] LOAD_TECHNOLOGY_SUCCESS',
7-
LOAD_TECHNOLOGY_FAIL = '[Technology] LOAD_TECHNOLOGY_FAIL',
5+
FIND_TECHNOLOGIES = '[Technology] FIND_TECHNOLOGIES',
6+
FIND_TECHNOLOGIES_SUCESS = '[Technology] FIND_TECHNOLOGIES_SUCESS',
7+
FIND_TECHNOLOGIES_FAIL = '[Technology] FIND_TECHNOLOGIES_FAIL ',
88
}
99

10-
export class LoadTechnology implements Action {
11-
public readonly type = TechnologyActionTypes.LOAD_TECHNOLOGY;
10+
export class FindTechnology implements Action {
11+
public readonly type = TechnologyActionTypes.FIND_TECHNOLOGIES;
1212

1313
constructor(readonly payload: string) {}
1414
}
1515

16-
export class LoadTechnologySuccess implements Action {
17-
readonly type = TechnologyActionTypes.LOAD_TECHNOLOGY_SUCCESS;
16+
export class FindTechnologySuccess implements Action {
17+
readonly type = TechnologyActionTypes.FIND_TECHNOLOGIES_SUCESS;
1818

1919
constructor(readonly payload: Technology) {}
2020
}
2121

22-
export class LoadTechnologyFail implements Action {
23-
public readonly type = TechnologyActionTypes.LOAD_TECHNOLOGY_FAIL;
22+
export class FindTechnologyFail implements Action {
23+
public readonly type = TechnologyActionTypes.FIND_TECHNOLOGIES_FAIL;
2424

2525
constructor(public error: string) {}
2626
}
2727

28-
export type TechnologyActions = LoadTechnology | LoadTechnologySuccess | LoadTechnologyFail;
28+
export type TechnologyActions = FindTechnology | FindTechnologySuccess | FindTechnologyFail;

src/app/modules/shared/store/technology.effects.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ export class TechnologyEffects {
1111
constructor(private actions$: Actions, private technologyService: TechnologyService) {}
1212

1313
@Effect()
14-
loadTechnology$: Observable<Action> = this.actions$.pipe(
15-
ofType(actions.TechnologyActionTypes.LOAD_TECHNOLOGY),
16-
map((action: actions.LoadTechnology) => action.payload),
14+
findTechnology$: Observable<Action> = this.actions$.pipe(
15+
ofType(actions.TechnologyActionTypes.FIND_TECHNOLOGIES),
16+
map((action: actions.FindTechnology) => action.payload),
1717
mergeMap((value) =>
1818
this.technologyService.getTechnologies(value).pipe(
1919
map((technology) => {
20-
return new actions.LoadTechnologySuccess(technology);
20+
return new actions.FindTechnologySuccess(technology);
2121
}),
22-
catchError((error) => of(new actions.LoadTechnologyFail(error)))
22+
catchError((error) => of(new actions.FindTechnologyFail(error)))
2323
)
2424
)
2525
);

src/app/modules/shared/store/technology.reducers.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ import { Technology } from '../models/technology.model';
55
describe('technologyReducer', () => {
66
const initialState: TechnologyState = { technologyList: null, isLoading: false };
77

8-
it('on LoadTechnology, isLoading is true', () => {
9-
const action = new actions.LoadTechnology('java');
8+
it('on FindTechnology, isLoading is true', () => {
9+
const action = new actions.FindTechnology('java');
1010
const state = technologyReducer(initialState, action);
1111
expect(state.isLoading).toEqual(true);
1212
});
1313

14-
it('on LoadTechnologySuccess, technologiesFound are saved in the store', () => {
14+
it('on FindTechnologySuccess, technologiesFound are saved in the store', () => {
1515
const technologiesFound: Technology = { items: [{ name: 'java' }] };
16-
const action = new actions.LoadTechnologySuccess(technologiesFound);
16+
const action = new actions.FindTechnologySuccess(technologiesFound);
1717
const state = technologyReducer(initialState, action);
1818
expect(state.technologyList).toEqual(technologiesFound);
1919
});
2020

21-
it('on LoadTechnologyFail, technologyList equal []', () => {
22-
const action = new actions.LoadTechnologyFail('error');
21+
it('on FindTechnologyFail, technologyList equal []', () => {
22+
const action = new actions.FindTechnologyFail('error');
2323
const state = technologyReducer(initialState, action);
2424
expect(state.technologyList).toEqual([]);
2525
});

0 commit comments

Comments
 (0)