Skip to content

Commit 1f4dfa4

Browse files
committed
fix: #176 adding unit-tests
1 parent 36c5ae1 commit 1f4dfa4

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

src/app/modules/shared/components/technologies/technologies.component.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ export class TechnologiesComponent implements OnInit {
5454
}
5555

5656
addTechnology(name: string) {
57-
const index = this.selectedTechnologies.indexOf(name);
58-
if (index > -1) {
59-
this.removeTechnology(index);
60-
} else if (this.selectedTechnologies.length < this.MAX_NUM_TECHNOLOGIES) {
57+
if (this.selectedTechnologies.length < this.MAX_NUM_TECHNOLOGIES) {
6158
this.selectedTechnologies = [...this.selectedTechnologies, name];
6259
this.technologyAdded.emit(this.selectedTechnologies);
6360
this.showList = false;

src/app/modules/time-clock/pipes/time-details.pipe.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ describe('TimeDetailsPipe', () => {
55
const pipe = new TimeDetailsPipe();
66
expect(pipe).toBeTruthy();
77
});
8+
9+
it('adds a 0 if has one number', () => {
10+
const pipe = new TimeDetailsPipe();
11+
expect(pipe.formatAsTwoDigit('5')).toBe('05');
12+
});
813
});

src/app/modules/time-clock/store/entry.actions.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1+
import { TimeEntriesSummary } from './../models/time.entry.summary';
12
import * as actions from './entry.actions';
23

34
describe('Actions for Entries', () => {
5+
6+
it('LoadEntriesSummaryFail type is EntryActionTypes.LOAD_ENTRIES_SUMMARY_FAIL', () => {
7+
const action = new actions.LoadEntriesSummaryFail();
8+
expect(action.type).toEqual(actions.EntryActionTypes.LOAD_ENTRIES_SUMMARY_FAIL);
9+
});
10+
11+
it('LoadEntriesSummarySuccess type is EntryActionTypes.LOAD_ENTRIES_SUMMARY_SUCCESS', () => {
12+
const action = new actions.LoadEntriesSummarySuccess(null);
13+
expect(action.type).toEqual(actions.EntryActionTypes.LOAD_ENTRIES_SUMMARY_SUCCESS);
14+
});
15+
416
it('LoadActiveEntrySuccess type is EntryActionTypes.LOAD_ACTIVE_ENTRY_SUCCESS', () => {
517
const loadActiveEntrySuccess = new actions.LoadActiveEntrySuccess([]);
618
expect(loadActiveEntrySuccess.type).toEqual(actions.EntryActionTypes.LOAD_ACTIVE_ENTRY_SUCCESS);

src/app/modules/time-clock/store/entry.reducer.spec.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,26 @@ describe('entryReducer', () => {
2525
technologies: ['angular', 'typescript'],
2626
};
2727

28-
it('on LOAD_ENTRIES_SUMMARY, is Loading trye', () => {
28+
it('sets timeEntriesSummary from action on LOAD_ENTRIES_SUMMARY_SUCCESS', () => {
29+
const payload = null;
30+
const action = new actions.LoadEntriesSummarySuccess(payload);
31+
const state = entryReducer(initialState, action);
32+
expect(state.timeEntriesSummary).toBe(payload);
33+
});
34+
35+
it('sets message on LOAD_ACTIVE_ENTRY_FAIL', () => {
36+
const action = new actions.LoadActiveEntryFail('');
37+
const state = entryReducer(initialState, action);
38+
expect(state.message).toBe('Something went wrong fetching active entry!');
39+
});
40+
41+
it('sets timeEntriesSummary as empty on LOAD_ENTRIES_SUMMARY_FAIL', () => {
42+
const action = new actions.LoadEntriesSummaryFail();
43+
const state = entryReducer(initialState, action);
44+
expect(state.timeEntriesSummary).toEqual(emptyTimeEntriesSummary);
45+
});
46+
47+
it('on LOAD_ENTRIES_SUMMARY, is Loading true', () => {
2948
const action = new actions.LoadEntriesSummary();
3049
const state = entryReducer(initialState, action);
3150
expect(state.isLoading).toBe(true);

0 commit comments

Comments
 (0)