Skip to content

Commit 91f5114

Browse files
committed
fix: TT-593 unit test
1 parent 6e55792 commit 91f5114

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ describe('Reports Page', () => {
147147
expect(component.dtElement.dtInstance.then).toHaveBeenCalled();
148148
});
149149

150+
it(`When the user method is called, the emit method is called`, () => {
151+
const userId = 'abc123';
152+
spyOn(component.selectedUserId,'emit');
153+
component.user(userId);
154+
expect(component.selectedUserId.emit).toHaveBeenCalled();
155+
156+
});
157+
150158
afterEach(() => {
151159
fixture.destroy();
152160
});

src/app/modules/reports/components/time-range-form/time-range.component.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
77
import { InputDateComponent } from '../../../shared/components/input-date/input-date.component';
88
import * as entryActions from '../../../time-clock/store/entry.actions';
99
import * as moment from 'moment';
10+
import { SimpleChange } from '@angular/core';
1011

1112
describe('Reports Page', () => {
1213
describe('TimeRangeFormComponent', () => {
@@ -114,6 +115,15 @@ describe('Reports Page', () => {
114115
expect(component.onSubmit).toHaveBeenCalled();
115116
});
116117

118+
it('When the ngOnChanges method is called, the onSubmit method is called', () =>{
119+
const userId = 'abcd';
120+
spyOn(component, 'onSubmit');
121+
122+
component.ngOnChanges({userId: new SimpleChange(null, userId, false)});
123+
124+
expect(component.onSubmit).toHaveBeenCalled();
125+
});
126+
117127
afterEach(() => {
118128
fixture.destroy();
119129
});

src/app/modules/reports/pages/reports.component.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ describe('ReportsComponent', () => {
3232
expect(reportForm).toBeTruthy();
3333
expect(reportDataTable).toBeTruthy();
3434
}));
35+
36+
it(`Given the id of the user 'abc123' this is assigned to the variable userId`, () => {
37+
const userId = 'abc123';
38+
component.user(userId);
39+
expect(component.userId).toEqual('abc123');
40+
});
3541
});

0 commit comments

Comments
 (0)