Commits
Giuseppe Digilio authored 74e1e67126c
1 1 | import { NO_ERRORS_SCHEMA } from '@angular/core'; |
2 2 | import { |
3 3 | ComponentFixture, |
4 4 | TestBed, |
5 5 | } from '@angular/core/testing'; |
6 6 | import { ActivatedRoute } from '@angular/router'; |
7 7 | import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap'; |
8 8 | import { TranslateModule } from '@ngx-translate/core'; |
9 9 | |
10 + | import { APP_CONFIG } from '../../../config/app-config.interface'; |
11 + | import { environment } from '../../../environments/environment.test'; |
10 12 | import { buildPaginatedList } from '../../core/data/paginated-list.model'; |
11 13 | import { SearchService } from '../../core/shared/search/search.service'; |
12 14 | import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; |
13 15 | import { ActivatedRouteStub } from '../../shared/testing/active-router.stub'; |
14 16 | import { AdminNotifyDashboardComponent } from './admin-notify-dashboard.component'; |
15 17 | import { AdminNotifyMetricsComponent } from './admin-notify-metrics/admin-notify-metrics.component'; |
16 18 | import { AdminNotifyMessage } from './models/admin-notify-message.model'; |
17 19 | import { AdminNotifySearchResult } from './models/admin-notify-message-search-result.model'; |
18 20 | |
19 21 | describe('AdminNotifyDashboardComponent', () => { |
20 22 | let component: AdminNotifyDashboardComponent; |
21 23 | let fixture: ComponentFixture<AdminNotifyDashboardComponent>; |
22 24 | |
23 25 | let item1; |
24 26 | let item2; |
25 27 | let item3; |
26 28 | let searchResult1; |
27 29 | let searchResult2; |
28 30 | let searchResult3; |
29 31 | let results; |
30 32 | |
31 - | const mockBoxes = [ |
32 - | { title: 'admin-notify-dashboard.received-ldn', boxes: [ undefined, undefined, undefined, undefined, undefined ] }, |
33 - | { title: 'admin-notify-dashboard.generated-ldn', boxes: [ undefined, undefined, undefined, undefined, undefined ] }, |
33 + | const mockBoxes = [ |
34 + | { |
35 + | title: 'admin-notify-dashboard.received-ldn', |
36 + | boxes: [ |
37 + | { |
38 + | color: '#B8DAFF', |
39 + | title: 'admin-notify-dashboard.NOTIFY.incoming.accepted', |
40 + | config: 'NOTIFY.incoming.accepted', |
41 + | description: 'admin-notify-dashboard.NOTIFY.incoming.accepted.description', |
42 + | count: undefined, |
43 + | }, |
44 + | { |
45 + | color: '#D4EDDA', |
46 + | title: 'admin-notify-dashboard.NOTIFY.incoming.processed', |
47 + | config: 'NOTIFY.incoming.processed', |
48 + | description: 'admin-notify-dashboard.NOTIFY.incoming.processed.description', |
49 + | count: undefined, |
50 + | }, |
51 + | { |
52 + | color: '#FDBBC7', |
53 + | title: 'admin-notify-dashboard.NOTIFY.incoming.failure', |
54 + | config: 'NOTIFY.incoming.failure', |
55 + | description: 'admin-notify-dashboard.NOTIFY.incoming.failure.description', |
56 + | count: undefined, |
57 + | }, |
58 + | { |
59 + | color: '#FDBBC7', |
60 + | title: 'admin-notify-dashboard.NOTIFY.incoming.untrusted', |
61 + | config: 'NOTIFY.incoming.untrusted', |
62 + | description: 'admin-notify-dashboard.NOTIFY.incoming.untrusted.description', |
63 + | count: undefined, |
64 + | }, |
65 + | { |
66 + | color: '#43515F', |
67 + | title: 'admin-notify-dashboard.NOTIFY.incoming.involvedItems', |
68 + | textColor: '#fff', |
69 + | config: 'NOTIFY.incoming.involvedItems', |
70 + | description: 'admin-notify-dashboard.NOTIFY.incoming.involvedItems.description', |
71 + | count: undefined, |
72 + | }, |
73 + | ], |
74 + | }, |
75 + | { |
76 + | title: 'admin-notify-dashboard.generated-ldn', |
77 + | boxes: [ |
78 + | { |
79 + | color: '#D4EDDA', |
80 + | title: 'admin-notify-dashboard.NOTIFY.outgoing.delivered', |
81 + | config: 'NOTIFY.outgoing.delivered', |
82 + | description: 'admin-notify-dashboard.NOTIFY.outgoing.delivered.description', |
83 + | count: undefined, |
84 + | }, |
85 + | { |
86 + | color: '#B8DAFF', |
87 + | title: 'admin-notify-dashboard.NOTIFY.outgoing.queued', |
88 + | config: 'NOTIFY.outgoing.queued', |
89 + | description: 'admin-notify-dashboard.NOTIFY.outgoing.queued.description', |
90 + | count: undefined, |
91 + | }, |
92 + | { |
93 + | color: '#FDEEBB', |
94 + | title: 'admin-notify-dashboard.NOTIFY.outgoing.queued_for_retry', |
95 + | config: 'NOTIFY.outgoing.queued_for_retry', |
96 + | description: 'admin-notify-dashboard.NOTIFY.outgoing.queued_for_retry.description', |
97 + | count: undefined, |
98 + | }, |
99 + | { |
100 + | color: '#FDBBC7', |
101 + | title: 'admin-notify-dashboard.NOTIFY.outgoing.failure', |
102 + | config: 'NOTIFY.outgoing.failure', |
103 + | description: 'admin-notify-dashboard.NOTIFY.outgoing.failure.description', |
104 + | count: undefined, |
105 + | }, |
106 + | { |
107 + | color: '#43515F', |
108 + | title: 'admin-notify-dashboard.NOTIFY.outgoing.involvedItems', |
109 + | textColor: '#fff', |
110 + | config: 'NOTIFY.outgoing.involvedItems', |
111 + | description: 'admin-notify-dashboard.NOTIFY.outgoing.involvedItems.description', |
112 + | count: undefined, |
113 + | }, |
114 + | ], |
115 + | }, |
34 116 | ]; |
35 117 | |
36 118 | beforeEach(async () => { |
37 119 | item1 = Object.assign(new AdminNotifyMessage(), { uuid: 'e1c51c69-896d-42dc-8221-1d5f2ad5516e' }); |
38 120 | item2 = Object.assign(new AdminNotifyMessage(), { uuid: 'c8279647-1acc-41ae-b036-951d5f65649b' }); |
39 121 | item3 = Object.assign(new AdminNotifyMessage(), { uuid: 'c3bcbff5-ec0c-4831-8e4c-94b9c933ccac' }); |
40 122 | searchResult1 = Object.assign(new AdminNotifySearchResult(), { indexableObject: item1 }); |
41 123 | searchResult2 = Object.assign(new AdminNotifySearchResult(), { indexableObject: item2 }); |
42 124 | searchResult3 = Object.assign(new AdminNotifySearchResult(), { indexableObject: item3 }); |
43 125 | results = buildPaginatedList(undefined, [searchResult1, searchResult2, searchResult3]); |
44 126 | |
45 127 | await TestBed.configureTestingModule({ |
46 128 | imports: [TranslateModule.forRoot(), NgbNavModule, AdminNotifyDashboardComponent], |
47 129 | providers: [ |
130 + | { provide: APP_CONFIG, useValue: environment }, |
48 131 | { provide: SearchService, useValue: { search: () => createSuccessfulRemoteDataObject$(results) } }, |
49 132 | { provide: ActivatedRoute, useValue: new ActivatedRouteStub() }, |
50 133 | ], |
51 134 | schemas: [NO_ERRORS_SCHEMA], |
52 135 | }).overrideComponent(AdminNotifyDashboardComponent, { |
53 136 | remove: { |
54 137 | imports: [AdminNotifyMetricsComponent], |
55 138 | }, |
56 139 | }) |
57 140 | .compileComponents(); |