Commits
Davide Negretti authored d3c36248167
5 5 | import { RouterTestingModule } from '@angular/router/testing'; |
6 6 | import { NO_ERRORS_SCHEMA } from '@angular/core'; |
7 7 | import { ProcessDataService } from '../../core/data/processes/process-data.service'; |
8 8 | import { Process } from '../processes/process.model'; |
9 9 | import { EPersonDataService } from '../../core/eperson/eperson-data.service'; |
10 10 | import { EPerson } from '../../core/eperson/models/eperson.model'; |
11 11 | import { By } from '@angular/platform-browser'; |
12 12 | import { ProcessStatus } from '../processes/process-status.model'; |
13 13 | import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; |
14 14 | import { createPaginatedList } from '../../shared/testing/utils.test'; |
15 - | import { of as observableOf } from 'rxjs'; |
16 15 | import { PaginationService } from '../../core/pagination/pagination.service'; |
17 - | import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; |
18 - | import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; |
19 - | import { FindListOptions } from '../../core/data/request.models'; |
20 16 | import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub'; |
17 + | import { DatePipe } from '@angular/common'; |
21 18 | |
22 19 | describe('ProcessOverviewComponent', () => { |
23 20 | let component: ProcessOverviewComponent; |
24 21 | let fixture: ComponentFixture<ProcessOverviewComponent>; |
25 22 | |
26 23 | let processService: ProcessDataService; |
27 24 | let ePersonService: EPersonDataService; |
28 25 | let paginationService; |
29 26 | |
30 27 | let processes: Process[]; |
31 28 | let ePerson: EPerson; |
32 29 | |
30 + | const pipe = new DatePipe('en-US'); |
31 + | |
33 32 | function init() { |
34 33 | processes = [ |
35 34 | Object.assign(new Process(), { |
36 35 | processId: 1, |
37 36 | scriptName: 'script-name', |
38 - | startTime: '2020-03-19', |
39 - | endTime: '2020-03-19', |
37 + | startTime: '2020-03-19 00:30:00', |
38 + | endTime: '2020-03-19 23:30:00', |
40 39 | processStatus: ProcessStatus.COMPLETED |
41 40 | }), |
42 41 | Object.assign(new Process(), { |
43 42 | processId: 2, |
44 43 | scriptName: 'script-name', |
45 - | startTime: '2020-03-20', |
46 - | endTime: '2020-03-20', |
44 + | startTime: '2020-03-20 00:30:00', |
45 + | endTime: '2020-03-20 23:30:00', |
47 46 | processStatus: ProcessStatus.FAILED |
48 47 | }), |
49 48 | Object.assign(new Process(), { |
50 49 | processId: 3, |
51 50 | scriptName: 'another-script-name', |
52 - | startTime: '2020-03-21', |
53 - | endTime: '2020-03-21', |
51 + | startTime: '2020-03-21 00:30:00', |
52 + | endTime: '2020-03-21 23:30:00', |
54 53 | processStatus: ProcessStatus.RUNNING |
55 54 | }) |
56 55 | ]; |
57 56 | ePerson = Object.assign(new EPerson(), { |
58 57 | metadata: { |
59 58 | 'eperson.firstname': [ |
60 59 | { |
61 60 | value: 'John', |
62 61 | language: null |
63 62 | } |
128 127 | it('should display the eperson\'s name in the third column', () => { |
129 128 | rowElements.forEach((rowElement, index) => { |
130 129 | const el = rowElement.query(By.css('td:nth-child(3)')).nativeElement; |
131 130 | expect(el.textContent).toContain(ePerson.name); |
132 131 | }); |
133 132 | }); |
134 133 | |
135 134 | it('should display the start time in the fourth column', () => { |
136 135 | rowElements.forEach((rowElement, index) => { |
137 136 | const el = rowElement.query(By.css('td:nth-child(4)')).nativeElement; |
138 - | expect(el.textContent).toContain(processes[index].startTime); |
137 + | expect(el.textContent).toContain(pipe.transform(processes[index].startTime, component.dateFormat, 'UTC')); |
139 138 | }); |
140 139 | }); |
141 140 | |
142 141 | it('should display the end time in the fifth column', () => { |
143 142 | rowElements.forEach((rowElement, index) => { |
144 143 | const el = rowElement.query(By.css('td:nth-child(5)')).nativeElement; |
145 - | expect(el.textContent).toContain(processes[index].endTime); |
144 + | expect(el.textContent).toContain(pipe.transform(processes[index].endTime, component.dateFormat, 'UTC')); |
146 145 | }); |
147 146 | }); |
148 147 | |
149 148 | it('should display the status in the sixth column', () => { |
150 149 | rowElements.forEach((rowElement, index) => { |
151 150 | const el = rowElement.query(By.css('td:nth-child(6)')).nativeElement; |
152 151 | expect(el.textContent).toContain(processes[index].processStatus); |
153 152 | }); |
154 153 | }); |
155 154 | }); |
156 155 | }); |