Skip to content

Commit f66ebda

Browse files
committed
refactor(tests): more standalone ports #12698
1 parent d91a277 commit f66ebda

File tree

6 files changed

+182
-255
lines changed

6 files changed

+182
-255
lines changed

projects/igniteui-angular/src/lib/directives/radio/radio-group.directive.spec.ts

+22-33
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
import { Component, ViewChild } from '@angular/core';
22
import { TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
3-
import { IgxRadioModule, IgxRadioGroupDirective } from './radio-group.directive';
3+
import { IgxRadioGroupDirective } from './radio-group.directive';
44
import { FormsModule, ReactiveFormsModule, UntypedFormGroup, UntypedFormBuilder } from '@angular/forms';
55

66
import { configureTestSuite } from '../../test-utils/configure-suite';
77
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
88
import { By } from '@angular/platform-browser';
9+
import { IgxRadioComponent } from '../../radio/radio.component';
10+
import { NgFor } from '@angular/common';
911

1012
describe('IgxRadioGroupDirective', () => {
1113
configureTestSuite();
1214
beforeAll(waitForAsync(() => {
1315
TestBed.configureTestingModule({
14-
imports: [
15-
IgxRadioModule,
16-
FormsModule,
17-
ReactiveFormsModule,
18-
NoopAnimationsModule,
19-
RadioGroupComponent,
20-
RadioGroupSimpleComponent,
21-
RadioGroupWithModelComponent,
22-
RadioGroupRequiredComponent,
23-
RadioGroupReactiveFormsComponent,
24-
RadioGroupDeepProjectionComponent
25-
]
26-
})
16+
imports: [
17+
FormsModule,
18+
ReactiveFormsModule,
19+
NoopAnimationsModule,
20+
RadioGroupComponent,
21+
RadioGroupSimpleComponent,
22+
RadioGroupWithModelComponent,
23+
RadioGroupRequiredComponent,
24+
RadioGroupReactiveFormsComponent,
25+
RadioGroupDeepProjectionComponent
26+
]
27+
})
2728
.compileComponents();
2829
}));
2930

@@ -236,7 +237,7 @@ describe('IgxRadioGroupDirective', () => {
236237
dispatchRadioEvent('blur', domRadio, fixture);
237238
fixture.detectChanges();
238239
tick();
239-
240+
240241
//expect(radioGroup.invalid).toBe(true);
241242
expect(domRadio.classList.contains('igx-radio--invalid')).toBe(true);
242243

@@ -262,9 +263,7 @@ describe('IgxRadioGroupDirective', () => {
262263
</igx-radio-group>
263264
`,
264265
standalone: true,
265-
imports: [IgxRadioModule,
266-
FormsModule,
267-
ReactiveFormsModule]
266+
imports: [IgxRadioGroupDirective, IgxRadioComponent]
268267
})
269268
class RadioGroupSimpleComponent {
270269
@ViewChild('radioGroup', { read: IgxRadioGroupDirective, static: true }) public radioGroup: IgxRadioGroupDirective;
@@ -278,9 +277,7 @@ class RadioGroupSimpleComponent {
278277
</igx-radio-group>
279278
`,
280279
standalone: true,
281-
imports: [IgxRadioModule,
282-
FormsModule,
283-
ReactiveFormsModule]
280+
imports: [IgxRadioComponent, IgxRadioGroupDirective, NgFor]
284281
})
285282
class RadioGroupComponent {
286283
@ViewChild('radioGroup', { read: IgxRadioGroupDirective, static: true }) public radioGroup: IgxRadioGroupDirective;
@@ -294,9 +291,7 @@ class RadioGroupComponent {
294291
</igx-radio-group>
295292
`,
296293
standalone: true,
297-
imports: [IgxRadioModule,
298-
FormsModule,
299-
ReactiveFormsModule]
294+
imports: [IgxRadioComponent, IgxRadioGroupDirective, NgFor]
300295
})
301296
class RadioGroupRequiredComponent {
302297
@ViewChild('radioGroup', { read: IgxRadioGroupDirective, static: true }) public radioGroup: IgxRadioGroupDirective;
@@ -315,9 +310,7 @@ interface Person {
315310
</igx-radio-group>
316311
`,
317312
standalone: true,
318-
imports: [IgxRadioModule,
319-
FormsModule,
320-
ReactiveFormsModule]
313+
imports: [IgxRadioComponent, IgxRadioGroupDirective, NgFor, FormsModule]
321314
})
322315
class RadioGroupWithModelComponent {
323316
@ViewChild('radioGroupSeasons', { read: IgxRadioGroupDirective, static: true }) public radioGroup: IgxRadioGroupDirective;
@@ -343,9 +336,7 @@ class RadioGroupWithModelComponent {
343336
</form>
344337
`,
345338
standalone: true,
346-
imports: [IgxRadioModule,
347-
FormsModule,
348-
ReactiveFormsModule]
339+
imports: [IgxRadioComponent, IgxRadioGroupDirective, NgFor, ReactiveFormsModule]
349340
})
350341
class RadioGroupReactiveFormsComponent {
351342
public seasons = [
@@ -398,9 +389,7 @@ class RadioGroupReactiveFormsComponent {
398389
</form>
399390
`,
400391
standalone: true,
401-
imports: [IgxRadioModule,
402-
FormsModule,
403-
ReactiveFormsModule]
392+
imports: [IgxRadioComponent, IgxRadioGroupDirective, NgFor, ReactiveFormsModule]
404393
})
405394
class RadioGroupDeepProjectionComponent {
406395

projects/igniteui-angular/src/lib/directives/scroll-inertia/scroll_inertia.directive.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
ElementRef
88
} from '@angular/core';
99
import { TestBed, ComponentFixture, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
10-
import { IgxScrollInertiaModule, IgxScrollInertiaDirective } from './scroll_inertia.directive';
10+
import { IgxScrollInertiaDirective } from './scroll_inertia.directive';
1111

1212
import { configureTestSuite } from '../../test-utils/configure-suite';
1313
import { wait } from '../../test-utils/ui-interactions.spec';
@@ -18,9 +18,9 @@ describe('Scroll Inertia Directive - Rendering', () => {
1818
configureTestSuite();
1919
beforeAll(waitForAsync(() => {
2020
TestBed.configureTestingModule({
21-
imports: [IgxScrollInertiaModule, IgxTestScrollInertiaDirective,
22-
ScrollInertiaComponent]
23-
}).compileComponents().then(() => {
21+
imports: [IgxTestScrollInertiaDirective,
22+
ScrollInertiaComponent]
23+
}).compileComponents().then(() => {
2424
fix = TestBed.createComponent(ScrollInertiaComponent);
2525
fix.detectChanges();
2626
});
@@ -299,7 +299,7 @@ describe('Scroll Inertia Directive - Scrolling', () => {
299299
});
300300
});
301301

302-
/** igxScroll inertia for testing */
302+
/** igxScroll inertia for testing */
303303
@Directive({
304304
selector: '[igxTestScrollInertia]',
305305
standalone: true
@@ -339,7 +339,7 @@ export class IgxTestScrollInertiaDirective extends IgxScrollInertiaDirective {
339339
</div>
340340
`,
341341
standalone: true,
342-
imports: [IgxScrollInertiaModule]
342+
imports: [IgxTestScrollInertiaDirective]
343343
})
344344
export class ScrollInertiaComponent implements OnInit {
345345
@ViewChild('container', { static: true }) public container: ElementRef;

projects/igniteui-angular/src/lib/directives/text-selection/text-selection.directive.spec.ts

+27-25
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { Component, DebugElement, Directive, ElementRef, HostListener, ViewChild } from '@angular/core';
22
import { fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
4-
import { IgxTextSelectionModule } from './text-selection.directive';
54

65
import { configureTestSuite } from '../../test-utils/configure-suite';
6+
import { IgxTextSelectionDirective } from './text-selection.directive';
77

88
describe('IgxSelection', () => {
99
configureTestSuite();
1010
beforeAll(waitForAsync(() => {
1111
TestBed.configureTestingModule({
12-
imports: [IgxTextSelectionModule, TriggerTextSelectionComponent,
13-
TriggerTextSelectionOnClickComponent,
14-
TextSelectionWithMultipleFocusHandlersComponent,
15-
IgxTestFocusDirective]
16-
});
12+
imports: [
13+
TriggerTextSelectionComponent,
14+
TriggerTextSelectionOnClickComponent,
15+
TextSelectionWithMultipleFocusHandlersComponent,
16+
IgxTestFocusDirective
17+
]
18+
});
1719
}));
1820

1921

@@ -140,12 +142,25 @@ describe('IgxSelection', () => {
140142
}));
141143
});
142144

145+
@Directive({
146+
selector: '[igxTestFocusDirective]',
147+
standalone: true
148+
})
149+
class IgxTestFocusDirective {
150+
constructor(private element: ElementRef) { }
151+
152+
@HostListener('focus')
153+
public onFocus() {
154+
this.element.nativeElement.value = `$${this.element.nativeElement.value}`;
155+
}
156+
}
157+
143158
@Component({
144159
template: `
145160
<input type="text" [igxTextSelection]="true" value="Some custom value!" />
146161
`,
147162
standalone: true,
148-
imports: [IgxTextSelectionModule]
163+
imports: [IgxTextSelectionDirective]
149164
})
150165
class TriggerTextSelectionComponent { }
151166

@@ -154,7 +169,7 @@ class TriggerTextSelectionComponent { }
154169
<input #input [type]="inputType" [igxTextSelection]="selectValue" #select="igxTextSelection" (click)="select.trigger()" [value]="inputValue" />
155170
`,
156171
standalone: true,
157-
imports: [IgxTextSelectionModule]
172+
imports: [IgxTextSelectionDirective]
158173
})
159174
class TriggerTextSelectionOnClickComponent {
160175
public selectValue = true;
@@ -169,31 +184,18 @@ class TriggerTextSelectionOnClickComponent {
169184
resolve("I promise to return after one second!");
170185
}, 1000);
171186
});
172-
}
173-
}
187+
}
188+
}
174189

175-
@Component({
190+
@Component({
176191
template: `<input #input type="text" igxTestFocusDirective [igxTextSelection]="true" [value]="inputValue" />`,
177192
standalone: true,
178-
imports: [IgxTextSelectionModule]
193+
imports: [IgxTextSelectionDirective, IgxTestFocusDirective]
179194
})
180195
class TextSelectionWithMultipleFocusHandlersComponent {
181196
public inputValue: any = "12-34-56";
182197
}
183198

184-
@Directive({
185-
selector: '[igxTestFocusDirective]',
186-
standalone: true
187-
})
188-
class IgxTestFocusDirective {
189-
constructor(private element: ElementRef) { }
190-
191-
@HostListener('focus')
192-
public onFocus() {
193-
this.element.nativeElement.value = `$${this.element.nativeElement.value}`;
194-
}
195-
}
196-
197199
interface Types {
198200
[key: string]: any;
199201
}

projects/igniteui-angular/src/lib/directives/toggle/toggle.directive.spec.ts

+19-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, DebugElement, ViewChild, ElementRef
22
import { fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
5-
import { IgxToggleActionDirective, IgxToggleDirective, IgxToggleModule, IgxOverlayOutletDirective } from './toggle.directive';
5+
import { IgxToggleActionDirective, IgxToggleDirective, IgxOverlayOutletDirective } from './toggle.directive';
66
import {
77
IgxOverlayService, OverlaySettings, ConnectedPositioningStrategy,
88
AbsoluteScrollStrategy, AutoPositionStrategy, HorizontalAlignment
@@ -18,15 +18,17 @@ describe('IgxToggle', () => {
1818
const TOGGLER_CLASS = 'igx-toggle';
1919
beforeAll(waitForAsync(() => {
2020
TestBed.configureTestingModule({
21-
imports: [NoopAnimationsModule, IgxToggleModule, IgxToggleActionTestComponent,
22-
IgxToggleOutletComponent,
23-
IgxToggleServiceInjectComponent,
24-
IgxOverlayServiceComponent,
25-
IgxToggleTestComponent,
26-
TestWithOnPushComponent,
27-
TestWithThreeToggleActionsComponent]
28-
})
29-
.compileComponents();
21+
imports: [
22+
NoopAnimationsModule,
23+
IgxToggleActionTestComponent,
24+
IgxToggleOutletComponent,
25+
IgxToggleServiceInjectComponent,
26+
IgxOverlayServiceComponent,
27+
IgxToggleTestComponent,
28+
TestWithOnPushComponent,
29+
TestWithThreeToggleActionsComponent
30+
]
31+
}).compileComponents();
3032
}));
3133

3234
it('IgxToggleDirective is defined', () => {
@@ -625,7 +627,7 @@ describe('IgxToggle', () => {
625627
</div>
626628
`,
627629
standalone: true,
628-
imports: [IgxToggleModule]
630+
imports: [IgxToggleDirective]
629631
})
630632
export class IgxToggleTestComponent {
631633
@ViewChild(IgxToggleDirective, { static: true }) public toggle: IgxToggleDirective;
@@ -646,7 +648,7 @@ export class IgxToggleTestComponent {
646648
</div>
647649
`,
648650
standalone: true,
649-
imports: [IgxToggleModule]
651+
imports: [IgxToggleDirective, IgxToggleActionDirective]
650652
})
651653
export class IgxToggleActionTestComponent {
652654
@ViewChild(IgxToggleDirective, { static: true }) public toggle: IgxToggleDirective;
@@ -664,7 +666,7 @@ export class IgxToggleActionTestComponent {
664666
<div igxOverlayOutlet #outlet="overlay-outlet" class="outlet-container"></div>
665667
`,
666668
standalone: true,
667-
imports: [IgxToggleModule]
669+
imports: [IgxToggleActionDirective, IgxToggleDirective, IgxOverlayOutletDirective]
668670
})
669671
export class IgxToggleOutletComponent extends IgxToggleActionTestComponent { }
670672

@@ -676,7 +678,7 @@ export class IgxToggleOutletComponent extends IgxToggleActionTestComponent { }
676678
</div>
677679
`,
678680
standalone: true,
679-
imports: [IgxToggleModule]
681+
imports: [IgxToggleActionDirective, IgxToggleDirective]
680682
})
681683
export class IgxToggleServiceInjectComponent {
682684
@ViewChild(IgxToggleDirective, { static: true }) public toggle: IgxToggleDirective;
@@ -694,7 +696,7 @@ export class IgxToggleServiceInjectComponent {
694696
`,
695697
changeDetection: ChangeDetectionStrategy.OnPush,
696698
standalone: true,
697-
imports: [IgxToggleModule]
699+
imports: [IgxToggleDirective]
698700
})
699701
export class IgxOverlayServiceComponent {
700702
@ViewChild(IgxToggleDirective, { static: true }) public toggle: IgxToggleDirective;
@@ -714,7 +716,7 @@ export class IgxOverlayServiceComponent {
714716
`,
715717
changeDetection: ChangeDetectionStrategy.OnPush,
716718
standalone: true,
717-
imports: [IgxToggleModule]
719+
imports: [IgxToggleActionDirective, IgxToggleDirective]
718720
})
719721
export class TestWithOnPushComponent {
720722
@ViewChild(IgxToggleDirective, { static: true }) public toggle: IgxToggleDirective;
@@ -744,7 +746,7 @@ export class TestWithOnPushComponent {
744746
</div>
745747
`,
746748
standalone: true,
747-
imports: [IgxToggleModule]
749+
imports: [IgxToggleActionDirective, IgxToggleDirective]
748750
})
749751
export class TestWithThreeToggleActionsComponent implements OnInit {
750752
@ViewChild('button1', { static: true }) public button1: ElementRef;

0 commit comments

Comments
 (0)