-
Notifications
You must be signed in to change notification settings - Fork 118
/
stream-deploy.component.spec.ts
132 lines (119 loc) · 5.48 KB
/
stream-deploy.component.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MockNotificationService } from '../../tests/mocks/notification';
import { MockStreamsService } from '../../tests/mocks/streams';
import { StreamsService } from '../streams.service';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { MockActivatedRoute } from '../../tests/mocks/activated-route';
import { ActivatedRoute } from '@angular/router';
import { StreamDeployComponent } from './stream-deploy.component';
import { MockComponent } from '../../tests/mocks/mock-component';
import { MocksSharedAboutService } from '../../tests/mocks/shared-about';
import { SharedAboutService } from '../../shared/services/shared-about.service';
import { BsDropdownModule, ModalModule, TooltipModule } from 'ngx-bootstrap';
import { AppTypeComponent } from '../../apps/components/app-type/app-type.component';
import { NotificationService } from '../../shared/services/notification.service';
import { LoggerService } from '../../shared/services/logger.service';
import { DATAFLOW_PAGE } from 'src/app/shared/components/page/page.component';
import { PagerComponent } from '../../shared/components/pager/pager.component';
import { DATAFLOW_LIST } from '../../shared/components/list/list.component';
import { RoutingStateService } from '../../shared/services/routing-state.service';
import { MockRoutingStateService } from '../../tests/mocks/routing-state';
import { LoaderComponent } from '../../shared/components/loader/loader.component';
import { StreamDeployFreeTextComponent } from './free-text/free-text.component';
import { StreamDeployBuilderComponent } from './builder/builder.component';
import { NgxPaginationModule } from 'ngx-pagination/dist/ngx-pagination';
import { StreamDeployBuilderErrorsComponent } from './builder/errors/errors.component';
import { FocusDirective } from '../../shared/directives/focus.directive';
import { StreamDeployService } from 'src/app/streams/stream-deploy/stream-deploy.service';
import { MockSharedAppService } from 'src/app/tests/mocks/shared-app';
import { MockAppsService } from '../../tests/mocks/apps';
import { ClipboardModule, ClipboardService } from 'ngx-clipboard';
import { BlockerService } from '../../shared/components/blocker/blocker.service';
/**
* Test {@link StreamDeployComponent}.
*
* @author Glenn Renfro
*/
describe('StreamDeployComponent', () => {
let component: StreamDeployComponent;
let fixture: ComponentFixture<StreamDeployComponent>;
const notificationService = new MockNotificationService();
const streamsService = new MockStreamsService();
const sharedAboutService = new MocksSharedAboutService();
const appsService = new MockAppsService();
const sharedAppService = new MockSharedAppService();
let activeRoute: MockActivatedRoute;
const commonTestParams = { id: '1' };
const loggerService = new LoggerService();
const routingStateService = new MockRoutingStateService();
const streamDeployService = new StreamDeployService(streamsService as any, sharedAppService, appsService as any);
beforeEach(async(() => {
activeRoute = new MockActivatedRoute();
TestBed.configureTestingModule({
declarations: [
StreamDeployComponent,
PagerComponent,
DATAFLOW_PAGE,
DATAFLOW_LIST,
LoaderComponent,
AppTypeComponent,
StreamDeployFreeTextComponent,
StreamDeployBuilderComponent,
StreamDeployBuilderErrorsComponent,
FocusDirective
],
imports: [
FormsModule,
ReactiveFormsModule,
TooltipModule.forRoot(),
ModalModule.forRoot(),
BsDropdownModule.forRoot(),
NgxPaginationModule,
ClipboardModule,
RouterTestingModule.withRoutes([{ path: 'streams/definitions', component: MockComponent }])
],
providers: [
{ provide: StreamsService, useValue: streamsService },
{ provide: ActivatedRoute, useValue: activeRoute },
{ provide: SharedAboutService, useValue: sharedAboutService },
{ provide: NotificationService, useValue: notificationService },
{ provide: RoutingStateService, useValue: routingStateService },
{ provide: StreamDeployService, useValue: streamDeployService },
{ provide: LoggerService, useValue: loggerService },
ClipboardService,
BlockerService
]
})
.compileComponents();
}));
beforeEach(() => {
activeRoute.testParams = commonTestParams;
fixture = TestBed.createComponent(StreamDeployComponent);
component = fixture.componentInstance;
notificationService.clearAll();
});
it('should be created', () => {
fixture.detectChanges();
expect(component).toBeTruthy();
});
describe('Run Copy', () => {
it('should copy and display a success message', () => {
component.runCopy(['a=a', 'b=b']);
fixture.detectChanges();
expect(notificationService.testSuccess[0]).toContain('The properties have been copied to your clipboard.');
});
it('should display an error message (empty)', () => {
component.runCopy([]);
fixture.detectChanges();
expect(notificationService.testError[0]).toContain('There are no properties to copy.');
});
});
describe('Run Export', () => {
it('should display an error message (empty)', () => {
component.runExport([]);
fixture.detectChanges();
expect(notificationService.testError[0]).toContain('There are no properties to export.');
});
});
});