|
1 | 1 | // modeled after https://github.com/angular/angular/blob/cee2318110eeea115e5f6fc5bfc814cbaa7d90d8/modules/angular2/test/common/directives/ng_for_spec.ts |
2 | | -import { it, iit, describe, expect, inject, beforeEachProviders } from '@angular/core/testing'; |
3 | | -import { TestComponentBuilder } from '@angular/compiler/testing'; |
4 | | -import {Component, ViewChild, TemplateRef} from '@angular/core'; |
| 2 | +import { inject, addProviders, TestComponentBuilder } from '@angular/core/testing'; |
| 3 | +import { Component, ViewChild, TemplateRef } from '@angular/core'; |
5 | 4 | import * as Infragistics from '../../../src/igniteui.angular2'; |
6 | | -import {Northwind} from "../../../samples/data/northwind"; |
| 5 | +import { Northwind } from "../../../samples/data/northwind"; |
7 | 6 |
|
8 | 7 | export function main() { |
9 | 8 | describe('Infragistics Angular2 Combo', () => { |
| 9 | + |
10 | 10 | it('should initialize correctly', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { |
11 | 11 | var template = '<div><ig-combo [(widgetId)]="comboID" [(options)]="options" [changeDetectionInterval]="cdi" [(ngModel)]="combo.value1"></ig-combo></div>'; |
12 | 12 | return tcb.overrideTemplate(TestComponent, template) |
13 | 13 | .createAsync(TestComponent) |
14 | 14 | .then((fixture) => { |
15 | 15 | fixture.detectChanges(); |
16 | | - expect(fixture.debugElement.componentInstance.viewChild).toBeAnInstanceOf(Infragistics.IgComboComponent); |
| 16 | + expect(fixture.debugElement.componentInstance.viewChild instanceof Infragistics.IgComboComponent) |
| 17 | + .toBe(true); |
17 | 18 | }); |
18 | 19 | })); |
19 | 20 |
|
@@ -48,25 +49,27 @@ export function main() { |
48 | 49 | }); |
49 | 50 | })); |
50 | 51 |
|
51 | | - it('should reflect changes when a record in the data changes', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { |
52 | | - var template = '<div><ig-combo [(widgetId)]="comboID" [(options)]="options" [changeDetectionInterval]="cdi" [(ngModel)]="combo.value1"></ig-combo></div>'; |
53 | | - return new Promise((resolve, reject) => { |
54 | | - tcb.overrideTemplate(TestComponent, template) |
| 52 | + it('should reflect changes when a record in the data changes', (done) => { |
| 53 | + |
| 54 | + inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { |
| 55 | + var template = '<div><ig-combo [(widgetId)]="comboID" [(options)]="options" [changeDetectionInterval]="cdi" [(ngModel)]="combo.value1"></ig-combo></div>'; |
| 56 | + return tcb.overrideTemplate(TestComponent, template) |
55 | 57 | .createAsync(TestComponent) |
56 | 58 | .then((fixture) => { |
57 | 59 | fixture.detectChanges(); |
58 | 60 | fixture.componentInstance.northwind[19].ProductName = "Test"; |
| 61 | + |
59 | 62 | setTimeout(function () { |
60 | 63 | fixture.detectChanges(); |
| 64 | + |
61 | 65 | var elem = $("#combo1").igCombo("itemsFromIndex", 19)["element"]; |
62 | 66 | expect(elem.text()).toBe("Test"); |
63 | 67 | expect($("#combo1").igCombo("text")).toBe("Test"); |
64 | | - resolve(); |
| 68 | + done(); |
65 | 69 | }, 10); |
66 | 70 | }); |
67 | | - }); |
68 | | - })); |
69 | | - |
| 71 | + })(); /* manually invoke the injected functions */ |
| 72 | + }); |
70 | 73 | }); |
71 | 74 | } |
72 | 75 |
|
|
0 commit comments