1 | "use strict";
|
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7 | };
|
8 | var core_1 = require("@angular/core");
|
9 | var testing_1 = require("@angular/core/testing");
|
10 | var ChartComponent_1 = require("./ChartComponent");
|
11 | var ChartPointComponent_1 = require("./ChartPointComponent");
|
12 | var ChartSeriesComponent_1 = require("./ChartSeriesComponent");
|
13 | var ChartXAxisComponent_1 = require("./ChartXAxisComponent");
|
14 | var ChartYAxisComponent_1 = require("./ChartYAxisComponent");
|
15 | var HighchartsService_1 = require("./HighchartsService");
|
16 | var Mocks_1 = require("./Mocks");
|
17 | function main() {
|
18 | describe('ChartComponent', function () {
|
19 | var highchartsServiceMock;
|
20 | var TestComponent = (function () {
|
21 | function TestComponent() {
|
22 | }
|
23 | return TestComponent;
|
24 | }());
|
25 | TestComponent = __decorate([
|
26 | core_1.Component({
|
27 | selector: 'test-component',
|
28 | template: ''
|
29 | })
|
30 | ], TestComponent);
|
31 | beforeEach(function () {
|
32 | highchartsServiceMock = new Mocks_1.HighchartsServiceMock();
|
33 | testing_1.TestBed.configureTestingModule({
|
34 | declarations: [
|
35 | TestComponent,
|
36 | ChartComponent_1.ChartComponent,
|
37 | ChartPointComponent_1.ChartPointComponent,
|
38 | ChartSeriesComponent_1.ChartSeriesComponent,
|
39 | ChartXAxisComponent_1.ChartXAxisComponent,
|
40 | ChartYAxisComponent_1.ChartYAxisComponent,
|
41 | ],
|
42 | schemas: [
|
43 | core_1.CUSTOM_ELEMENTS_SCHEMA,
|
44 | ],
|
45 | });
|
46 | });
|
47 | var create = function (template) {
|
48 | return testing_1.TestBed.overrideComponent(TestComponent, {
|
49 | set: {
|
50 | template: template
|
51 | }
|
52 | }).overrideComponent(ChartComponent_1.ChartComponent, {
|
53 | set: {
|
54 | providers: [
|
55 | { provide: HighchartsService_1.HighchartsService, useValue: highchartsServiceMock }
|
56 | ]
|
57 | }
|
58 | }).compileComponents().then(function () {
|
59 | return testing_1.TestBed.createComponent(TestComponent);
|
60 | });
|
61 | };
|
62 | it('should create simple chart object', function (done) {
|
63 | create('<chart [options]="options"></chart>').then(function (fixture) {
|
64 | fixture.componentInstance.options = ['options'];
|
65 | spyOn(highchartsServiceMock.getHighchartsStatic(), 'Chart');
|
66 | fixture.detectChanges();
|
67 | expect(highchartsServiceMock.getHighchartsStatic().Chart).toHaveBeenCalled();
|
68 | done();
|
69 | });
|
70 | });
|
71 | it('should emit the "create" event with HighchartsChartObject', function (done) {
|
72 | create('<chart [options]="options" (create)="onCreated($event)"></chart>').then(function (fixture) {
|
73 | fixture.componentInstance.onCreated = function (e) {
|
74 | expect(e.constructor).toBe(Mocks_1.HighchartsChartObjectMock);
|
75 | done();
|
76 | };
|
77 | fixture.componentInstance.options = ['options'];
|
78 | fixture.detectChanges();
|
79 | });
|
80 | });
|
81 | it('should create chart asynchronously', function (done) {
|
82 | create('<chart [options]="options" (create)="onCreated($event)"></chart>').then(function (fixture) {
|
83 | fixture.componentInstance.onCreated = function (e) {
|
84 | expect(e.constructor).toBe(Mocks_1.HighchartsChartObjectMock);
|
85 | done();
|
86 | };
|
87 | setTimeout(function () {
|
88 | fixture.componentInstance.options = ['options'];
|
89 | fixture.detectChanges();
|
90 | });
|
91 | });
|
92 | });
|
93 | describe('should emit Highcharts chart event', function () {
|
94 | it('"load"', function (done) {
|
95 | create('<chart [options]="options" (load)="onEvent()"></chart>').then(function (fixture) {
|
96 | fixture.componentInstance.onEvent = function () { return done(); };
|
97 | fixture.componentInstance.options = ['options'];
|
98 | fixture.detectChanges();
|
99 | Mocks_1.ChartEventEmitter.emitChartEvent('load');
|
100 | });
|
101 | });
|
102 | it('"addSeries"', function (done) {
|
103 | create('<chart [options]="options" (addSeries)="onEvent()"></chart>').then(function (fixture) {
|
104 | fixture.componentInstance.onEvent = function () { return done(); };
|
105 | fixture.componentInstance.options = ['options'];
|
106 | fixture.detectChanges();
|
107 | Mocks_1.ChartEventEmitter.emitChartEvent('addSeries');
|
108 | });
|
109 | });
|
110 | it('"afterPrint"', function (done) {
|
111 | create('<chart [options]="options" (afterPrint)="onEvent()"></chart>').then(function (fixture) {
|
112 | fixture.componentInstance.onEvent = function () { return done(); };
|
113 | fixture.componentInstance.options = ['options'];
|
114 | fixture.detectChanges();
|
115 | Mocks_1.ChartEventEmitter.emitChartEvent('afterPrint');
|
116 | });
|
117 | });
|
118 | it('"beforePrint"', function (done) {
|
119 | create('<chart [options]="options" (beforePrint)="onEvent()"></chart>').then(function (fixture) {
|
120 | fixture.componentInstance.onEvent = function () { return done(); };
|
121 | fixture.componentInstance.options = ['options'];
|
122 | fixture.detectChanges();
|
123 | Mocks_1.ChartEventEmitter.emitChartEvent('beforePrint');
|
124 | });
|
125 | });
|
126 | it('"drilldown"', function (done) {
|
127 | create('<chart [options]="options" (drilldown)="onEvent()"></chart>').then(function (fixture) {
|
128 | fixture.componentInstance.onEvent = function () { return done(); };
|
129 | fixture.componentInstance.options = ['options'];
|
130 | fixture.detectChanges();
|
131 | Mocks_1.ChartEventEmitter.emitChartEvent('drilldown');
|
132 | });
|
133 | });
|
134 | it('"drillup"', function (done) {
|
135 | create('<chart [options]="options" (drillup)="onEvent()"></chart>').then(function (fixture) {
|
136 | fixture.componentInstance.onEvent = function () { return done(); };
|
137 | fixture.componentInstance.options = ['options'];
|
138 | fixture.detectChanges();
|
139 | Mocks_1.ChartEventEmitter.emitChartEvent('drillup');
|
140 | });
|
141 | });
|
142 | it('"load"', function (done) {
|
143 | create('<chart [options]="options" (load)="onEvent()"></chart>').then(function (fixture) {
|
144 | fixture.componentInstance.onEvent = function () { return done(); };
|
145 | fixture.componentInstance.options = ['options'];
|
146 | fixture.detectChanges();
|
147 | Mocks_1.ChartEventEmitter.emitChartEvent('load');
|
148 | });
|
149 | });
|
150 | it('"redraw"', function (done) {
|
151 | create('<chart [options]="options" (redraw)="onEvent()"></chart>').then(function (fixture) {
|
152 | fixture.componentInstance.onEvent = function () { return done(); };
|
153 | fixture.componentInstance.options = ['options'];
|
154 | fixture.detectChanges();
|
155 | Mocks_1.ChartEventEmitter.emitChartEvent('redraw');
|
156 | });
|
157 | });
|
158 | it('"selection"', function (done) {
|
159 | create('<chart [options]="options" (selection)="onEvent()"></chart>').then(function (fixture) {
|
160 | fixture.componentInstance.onEvent = function () { return done(); };
|
161 | fixture.componentInstance.options = ['options'];
|
162 | fixture.detectChanges();
|
163 | Mocks_1.ChartEventEmitter.emitChartEvent('selection');
|
164 | });
|
165 | });
|
166 | });
|
167 | describe('should emit Highcharts series event', function () {
|
168 | it('"afterAnimate"', function (done) {
|
169 | create("\n <chart [options]=\"options\">\n <series (afterAnimate)=\"onEvent()\"></series>\n </chart>\n ").then(function (fixture) {
|
170 | fixture.componentInstance.onEvent = function () { return done(); };
|
171 | fixture.componentInstance.options = ['options'];
|
172 | fixture.detectChanges();
|
173 | Mocks_1.ChartEventEmitter.emitSeriesEvent('afterAnimate');
|
174 | });
|
175 | });
|
176 | it('"checkboxClick"', function (done) {
|
177 | create("\n <chart [options]=\"options\">\n <series (checkboxClick)=\"onEvent()\"></series>\n </chart>\n ").then(function (fixture) {
|
178 | fixture.componentInstance.onEvent = function () { return done(); };
|
179 | fixture.componentInstance.options = ['options'];
|
180 | fixture.detectChanges();
|
181 | Mocks_1.ChartEventEmitter.emitSeriesEvent('checkboxClick');
|
182 | });
|
183 | });
|
184 | it('"click"', function (done) {
|
185 | create("\n <chart [options]=\"options\">\n <series (click)=\"onEvent()\"></series>\n </chart>\n ").then(function (fixture) {
|
186 | fixture.componentInstance.onEvent = function () { return done(); };
|
187 | fixture.componentInstance.options = ['options'];
|
188 | fixture.detectChanges();
|
189 | Mocks_1.ChartEventEmitter.emitSeriesEvent('click');
|
190 | });
|
191 | });
|
192 | it('"hide"', function (done) {
|
193 | create("\n <chart [options]=\"options\">\n <series (hide)=\"onEvent()\"></series>\n </chart>\n ").then(function (fixture) {
|
194 | fixture.componentInstance.onEvent = function () { return done(); };
|
195 | fixture.componentInstance.options = ['options'];
|
196 | fixture.detectChanges();
|
197 | Mocks_1.ChartEventEmitter.emitSeriesEvent('hide');
|
198 | });
|
199 | });
|
200 | it('"legendItemClick"', function (done) {
|
201 | create("\n <chart [options]=\"options\">\n <series (legendItemClick)=\"onEvent()\"></series>\n </chart>\n ").then(function (fixture) {
|
202 | fixture.componentInstance.onEvent = function () { return done(); };
|
203 | fixture.componentInstance.options = ['options'];
|
204 | fixture.detectChanges();
|
205 | Mocks_1.ChartEventEmitter.emitSeriesEvent('legendItemClick');
|
206 | });
|
207 | });
|
208 | it('"mouseOut"', function (done) {
|
209 | create("\n <chart [options]=\"options\">\n <series (mouseOut)=\"onEvent()\"></series>\n </chart>\n ").then(function (fixture) {
|
210 | fixture.componentInstance.onEvent = function () { return done(); };
|
211 | fixture.componentInstance.options = ['options'];
|
212 | fixture.detectChanges();
|
213 | Mocks_1.ChartEventEmitter.emitSeriesEvent('mouseOut');
|
214 | });
|
215 | });
|
216 | it('"mouseOver"', function (done) {
|
217 | create("\n <chart [options]=\"options\">\n <series (mouseOver)=\"onEvent()\"></series>\n </chart>\n ").then(function (fixture) {
|
218 | fixture.componentInstance.onEvent = function () { return done(); };
|
219 | fixture.componentInstance.options = ['options'];
|
220 | fixture.detectChanges();
|
221 | Mocks_1.ChartEventEmitter.emitSeriesEvent('mouseOver');
|
222 | });
|
223 | });
|
224 | it('"show"', function (done) {
|
225 | create("\n <chart [options]=\"options\">\n <series (show)=\"onEvent()\"></series>\n </chart>\n ").then(function (fixture) {
|
226 | fixture.componentInstance.onEvent = function () { return done(); };
|
227 | fixture.componentInstance.options = ['options'];
|
228 | fixture.detectChanges();
|
229 | Mocks_1.ChartEventEmitter.emitSeriesEvent('show');
|
230 | });
|
231 | });
|
232 | });
|
233 | describe('should emit Highcharts point event', function () {
|
234 | it('"click"', function (done) {
|
235 | create("\n <chart [options]=\"options\">\n <series>\n <point (click)=\"onEvent()\">\n </point>\n </series>\n </chart>\n ").then(function (fixture) {
|
236 | fixture.componentInstance.onEvent = function () { return done(); };
|
237 | fixture.componentInstance.options = ['options'];
|
238 | fixture.detectChanges();
|
239 | Mocks_1.ChartEventEmitter.emitPointEvent('click');
|
240 | });
|
241 | });
|
242 | it('"mouseOut"', function (done) {
|
243 | create("\n <chart [options]=\"options\">\n <series>\n <point (mouseOut)=\"onEvent()\">\n </point>\n </series>\n </chart>\n ").then(function (fixture) {
|
244 | fixture.componentInstance.onEvent = function () { return done(); };
|
245 | fixture.componentInstance.options = ['options'];
|
246 | fixture.detectChanges();
|
247 | Mocks_1.ChartEventEmitter.emitPointEvent('mouseOut');
|
248 | });
|
249 | });
|
250 | it('"mouseOver"', function (done) {
|
251 | create("\n <chart [options]=\"options\">\n <series>\n <point (mouseOver)=\"onEvent()\">\n </point>\n </series>\n </chart>\n ").then(function (fixture) {
|
252 | fixture.componentInstance.onEvent = function () { return done(); };
|
253 | fixture.componentInstance.options = ['options'];
|
254 | fixture.detectChanges();
|
255 | Mocks_1.ChartEventEmitter.emitPointEvent('mouseOver');
|
256 | });
|
257 | });
|
258 | it('"remove"', function (done) {
|
259 | create("\n <chart [options]=\"options\">\n <series>\n <point (remove)=\"onEvent()\">\n </point>\n </series>\n </chart>\n ").then(function (fixture) {
|
260 | fixture.componentInstance.onEvent = function () { return done(); };
|
261 | fixture.componentInstance.options = ['options'];
|
262 | fixture.detectChanges();
|
263 | Mocks_1.ChartEventEmitter.emitPointEvent('remove');
|
264 | });
|
265 | });
|
266 | it('"select"', function (done) {
|
267 | create("\n <chart [options]=\"options\">\n <series>\n <point (select)=\"onEvent()\">\n </point>\n </series>\n </chart>\n ").then(function (fixture) {
|
268 | fixture.componentInstance.onEvent = function () { return done(); };
|
269 | fixture.componentInstance.options = ['options'];
|
270 | fixture.detectChanges();
|
271 | Mocks_1.ChartEventEmitter.emitPointEvent('select');
|
272 | });
|
273 | });
|
274 | it('"unselect"', function (done) {
|
275 | create("\n <chart [options]=\"options\">\n <series>\n <point (unselect)=\"onEvent()\">\n </point>\n </series>\n </chart>\n ").then(function (fixture) {
|
276 | fixture.componentInstance.onEvent = function () { return done(); };
|
277 | fixture.componentInstance.options = ['options'];
|
278 | fixture.detectChanges();
|
279 | Mocks_1.ChartEventEmitter.emitPointEvent('unselect');
|
280 | });
|
281 | });
|
282 | it('"update"', function (done) {
|
283 | create("\n <chart [options]=\"options\">\n <series>\n <point (update)=\"onEvent()\">\n </point>\n </series>\n </chart>\n ").then(function (fixture) {
|
284 | fixture.componentInstance.onEvent = function () { return done(); };
|
285 | fixture.componentInstance.options = ['options'];
|
286 | fixture.detectChanges();
|
287 | Mocks_1.ChartEventEmitter.emitPointEvent('update');
|
288 | });
|
289 | });
|
290 | });
|
291 | describe('should emit Highcharts xAxis event', function () {
|
292 | it('"afterBreaks"', function (done) {
|
293 | create("\n <chart [options]=\"options\">\n <xAxis (afterBreaks)=\"onEvent()\">\n </xAxis>\n </chart>\n ").then(function (fixture) {
|
294 | fixture.componentInstance.onEvent = function () { return done(); };
|
295 | fixture.componentInstance.options = ['options'];
|
296 | fixture.detectChanges();
|
297 | Mocks_1.ChartEventEmitter.emitXAxisEvent('afterBreaks');
|
298 | });
|
299 | });
|
300 | it('"afterSetExtremes"', function (done) {
|
301 | create("\n <chart [options]=\"options\">\n <xAxis (afterSetExtremes)=\"onEvent()\">\n </xAxis>\n </chart>\n ").then(function (fixture) {
|
302 | fixture.componentInstance.onEvent = function () { return done(); };
|
303 | fixture.componentInstance.options = ['options'];
|
304 | fixture.detectChanges();
|
305 | Mocks_1.ChartEventEmitter.emitXAxisEvent('afterSetExtremes');
|
306 | });
|
307 | });
|
308 | it('"pointBreak"', function (done) {
|
309 | create("\n <chart [options]=\"options\">\n <xAxis (pointBreak)=\"onEvent()\">\n </xAxis>\n </chart>\n ").then(function (fixture) {
|
310 | fixture.componentInstance.onEvent = function () { return done(); };
|
311 | fixture.componentInstance.options = ['options'];
|
312 | fixture.detectChanges();
|
313 | Mocks_1.ChartEventEmitter.emitXAxisEvent('pointBreak');
|
314 | });
|
315 | });
|
316 | it('"pointInBreak"', function (done) {
|
317 | create("\n <chart [options]=\"options\">\n <xAxis (pointInBreak)=\"onEvent()\">\n </xAxis>\n </chart>\n ").then(function (fixture) {
|
318 | fixture.componentInstance.onEvent = function () { return done(); };
|
319 | fixture.componentInstance.options = ['options'];
|
320 | fixture.detectChanges();
|
321 | Mocks_1.ChartEventEmitter.emitXAxisEvent('pointInBreak');
|
322 | });
|
323 | });
|
324 | it('"setExtremes"', function (done) {
|
325 | create("\n <chart [options]=\"options\">\n <xAxis (setExtremes)=\"onEvent()\">\n </xAxis>\n </chart>\n ").then(function (fixture) {
|
326 | fixture.componentInstance.onEvent = function () { return done(); };
|
327 | fixture.componentInstance.options = ['options'];
|
328 | fixture.detectChanges();
|
329 | Mocks_1.ChartEventEmitter.emitXAxisEvent('setExtremes');
|
330 | });
|
331 | });
|
332 | });
|
333 | describe('should emit Highcharts yAxis event', function () {
|
334 | it('"afterBreaks"', function (done) {
|
335 | create("\n <chart [options]=\"options\">\n <yAxis (afterBreaks)=\"onEvent()\">\n </yAxis>\n </chart>\n ").then(function (fixture) {
|
336 | fixture.componentInstance.onEvent = function () { return done(); };
|
337 | fixture.componentInstance.options = ['options'];
|
338 | fixture.detectChanges();
|
339 | Mocks_1.ChartEventEmitter.emitYAxisEvent('afterBreaks');
|
340 | });
|
341 | });
|
342 | it('"afterSetExtremes"', function (done) {
|
343 | create("\n <chart [options]=\"options\">\n <yAxis (afterSetExtremes)=\"onEvent()\">\n </yAxis>\n </chart>\n ").then(function (fixture) {
|
344 | fixture.componentInstance.onEvent = function () { return done(); };
|
345 | fixture.componentInstance.options = ['options'];
|
346 | fixture.detectChanges();
|
347 | Mocks_1.ChartEventEmitter.emitYAxisEvent('afterSetExtremes');
|
348 | });
|
349 | });
|
350 | it('"pointBreak"', function (done) {
|
351 | create("\n <chart [options]=\"options\">\n <yAxis (pointBreak)=\"onEvent()\">\n </yAxis>\n </chart>\n ").then(function (fixture) {
|
352 | fixture.componentInstance.onEvent = function () { return done(); };
|
353 | fixture.componentInstance.options = ['options'];
|
354 | fixture.detectChanges();
|
355 | Mocks_1.ChartEventEmitter.emitYAxisEvent('pointBreak');
|
356 | });
|
357 | });
|
358 | it('"pointInBreak"', function (done) {
|
359 | create("\n <chart [options]=\"options\">\n <yAxis (pointInBreak)=\"onEvent()\">\n </yAxis>\n </chart>\n ").then(function (fixture) {
|
360 | fixture.componentInstance.onEvent = function () { return done(); };
|
361 | fixture.componentInstance.options = ['options'];
|
362 | fixture.detectChanges();
|
363 | Mocks_1.ChartEventEmitter.emitYAxisEvent('pointInBreak');
|
364 | });
|
365 | });
|
366 | it('"setExtremes"', function (done) {
|
367 | create("\n <chart [options]=\"options\">\n <yAxis (setExtremes)=\"onEvent()\">\n </yAxis>\n </chart>\n ").then(function (fixture) {
|
368 | fixture.componentInstance.onEvent = function () { return done(); };
|
369 | fixture.componentInstance.options = ['options'];
|
370 | fixture.detectChanges();
|
371 | Mocks_1.ChartEventEmitter.emitYAxisEvent('setExtremes');
|
372 | });
|
373 | });
|
374 | });
|
375 | });
|
376 | }
|
377 | exports.main = main;
|
378 |
|
\ | No newline at end of file |