|
1 | | -// import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
2 | | -// import { MockStore, provideMockStore } from '@ngrx/store/testing'; |
3 | | -// import { Entry } from 'src/app/modules/shared/models'; |
4 | | -// import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe'; |
5 | | -// import { getReportDataSource } from 'src/app/modules/time-clock/store/entry.selectors'; |
6 | | -// import { EntryState } from '../../../time-clock/store/entry.reducer'; |
7 | | -// import { TimeEntriesTableComponent } from './time-entries-table.component'; |
| 1 | +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
| 2 | +import { MockStore, provideMockStore } from '@ngrx/store/testing'; |
| 3 | +import { Entry } from 'src/app/modules/shared/models'; |
| 4 | +import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe'; |
| 5 | +import { getReportDataSource } from 'src/app/modules/time-clock/store/entry.selectors'; |
| 6 | +import { EntryState } from '../../../time-clock/store/entry.reducer'; |
| 7 | +import { TechnologyReportTableComponent } from './technology-report-table.component'; |
8 | 8 |
|
9 | | -// describe('Reports Page', () => { |
10 | | -// describe('TimeEntriesTableComponent', () => { |
11 | | -// let component: TimeEntriesTableComponent; |
12 | | -// let fixture: ComponentFixture<TimeEntriesTableComponent>; |
13 | | -// let store: MockStore<EntryState>; |
14 | | -// let getReportDataSourceSelectorMock; |
15 | | -// const timeEntry: Entry = { |
16 | | -// id: '123', |
17 | | -// start_date: new Date(), |
18 | | -// end_date: new Date(), |
19 | | -// activity_id: '123', |
20 | | -// technologies: ['react', 'redux'], |
21 | | -// description: 'any comment', |
22 | | -// uri: 'custom uri', |
23 | | -// project_id: '123', |
24 | | -// project_name: 'Time-Tracker' |
25 | | -// }; |
| 9 | +describe('Reports Page', () => { |
| 10 | + describe('TimeEntriesTableComponent', () => { |
| 11 | + let component: TechnologyReportTableComponent; |
| 12 | + let fixture: ComponentFixture<TechnologyReportTableComponent>; |
| 13 | + let store: MockStore<EntryState>; |
| 14 | + let getReportDataSourceSelectorMock; |
| 15 | + const timeEntry: Entry = { |
| 16 | + start_date: new Date(), |
| 17 | + end_date: new Date(), |
| 18 | + technologies: ['react', 'redux'], |
| 19 | + }; |
26 | 20 |
|
27 | | -// const state: EntryState = { |
28 | | -// active: timeEntry, |
29 | | -// isLoading: false, |
30 | | -// message: '', |
31 | | -// createError: false, |
32 | | -// updateError: false, |
33 | | -// timeEntriesSummary: null, |
34 | | -// timeEntriesDataSource: { |
35 | | -// data: [timeEntry], |
36 | | -// isLoading: false |
37 | | -// }, |
38 | | -// reportDataSource: { |
39 | | -// data: [timeEntry], |
40 | | -// isLoading: false |
41 | | -// } |
42 | | -// }; |
| 21 | + const state: EntryState = { |
| 22 | + active: timeEntry, |
| 23 | + isLoading: false, |
| 24 | + message: '', |
| 25 | + createError: false, |
| 26 | + updateError: false, |
| 27 | + timeEntriesSummary: null, |
| 28 | + timeEntriesDataSource: { |
| 29 | + data: [timeEntry], |
| 30 | + isLoading: false |
| 31 | + }, |
| 32 | + reportDataSource: { |
| 33 | + data: [timeEntry], |
| 34 | + isLoading: false |
| 35 | + } |
| 36 | + }; |
43 | 37 |
|
44 | | -// beforeEach(async(() => { |
45 | | -// TestBed.configureTestingModule({ |
46 | | -// imports: [], |
47 | | -// declarations: [TimeEntriesTableComponent, SubstractDatePipe], |
48 | | -// providers: [provideMockStore({ initialState: state })], |
49 | | -// }).compileComponents(); |
50 | | -// store = TestBed.inject(MockStore); |
| 38 | + beforeEach(async(() => { |
| 39 | + TestBed.configureTestingModule({ |
| 40 | + imports: [], |
| 41 | + declarations: [TechnologyReportTableComponent, SubstractDatePipe], |
| 42 | + providers: [provideMockStore({ initialState: state })], |
| 43 | + }).compileComponents(); |
| 44 | + store = TestBed.inject(MockStore); |
51 | 45 |
|
52 | | -// })); |
| 46 | + })); |
53 | 47 |
|
54 | | -// beforeEach(async(() => { |
55 | | -// fixture = TestBed.createComponent(TimeEntriesTableComponent); |
56 | | -// component = fixture.componentInstance; |
57 | | -// store.setState(state); |
58 | | -// getReportDataSourceSelectorMock = store.overrideSelector(getReportDataSource, state.reportDataSource); |
59 | | -// fixture.detectChanges(); |
60 | | -// })); |
| 48 | + beforeEach(async(() => { |
| 49 | + fixture = TestBed.createComponent(TechnologyReportTableComponent); |
| 50 | + component = fixture.componentInstance; |
| 51 | + store.setState(state); |
| 52 | + getReportDataSourceSelectorMock = store.overrideSelector(getReportDataSource, state.reportDataSource); |
| 53 | + fixture.detectChanges(); |
| 54 | + })); |
61 | 55 |
|
62 | | -// it('component should be created', async () => { |
63 | | -// expect(component).toBeTruthy(); |
64 | | -// }); |
| 56 | + fit('component should be created', async () => { |
| 57 | + expect(component).toBeTruthy(); |
| 58 | + }); |
65 | 59 |
|
66 | | -// it('on success load time entries, the report should be populated', () => { |
67 | | -// component.reportDataSource$.subscribe(ds => { |
68 | | -// expect(ds.data).toEqual(state.reportDataSource.data); |
69 | | -// }); |
70 | | -// }); |
| 60 | + // it('on success load time entries, the report should be populated', () => { |
| 61 | + // component.reportDataSource$.subscribe(ds => { |
| 62 | + // expect(ds.data).toEqual(state.reportDataSource.data); |
| 63 | + // }); |
| 64 | + // }); |
71 | 65 |
|
72 | | -// it('after the component is initialized it should initialize the table', () => { |
73 | | -// spyOn(component.dtTrigger, 'next'); |
74 | | -// component.ngAfterViewInit(); |
| 66 | + // it('after the component is initialized it should initialize the table', () => { |
| 67 | + // spyOn(component.dtTrigger, 'next'); |
| 68 | + // component.ngAfterViewInit(); |
75 | 69 |
|
76 | | -// expect(component.dtTrigger.next).toHaveBeenCalled(); |
77 | | -// }); |
| 70 | + // expect(component.dtTrigger.next).toHaveBeenCalled(); |
| 71 | + // }); |
78 | 72 |
|
79 | | -// afterEach(() => { |
80 | | -// fixture.destroy(); |
81 | | -// }); |
82 | | -// }); |
83 | | -// }); |
| 73 | + afterEach(() => { |
| 74 | + fixture.destroy(); |
| 75 | + }); |
| 76 | + }); |
| 77 | +}); |
0 commit comments