|
1 | 1 | import { IgxInputState } from './../directives/input/input.directive';
|
2 |
| -import { Component, ViewChild, DebugElement, OnInit } from '@angular/core'; |
| 2 | +import { Component, ViewChild, DebugElement } from '@angular/core'; |
3 | 3 | import { async, TestBed, tick, fakeAsync } from '@angular/core/testing';
|
4 | 4 | import { FormsModule, FormGroup, FormBuilder, FormControl, Validators, ReactiveFormsModule, NgForm } from '@angular/forms';
|
5 | 5 | import { By } from '@angular/platform-browser';
|
6 | 6 | import { IgxDropDownModule } from '../drop-down/index';
|
7 | 7 | import { IgxIconModule } from '../icon/index';
|
8 | 8 | import { IgxInputGroupModule } from '../input-group/index';
|
9 | 9 | import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
10 |
| -import { IgxSelectComponent} from './select.component'; |
| 10 | +import { IgxSelectComponent } from './select.component'; |
11 | 11 | import { IgxSelectItemComponent } from './select-item.component';
|
12 | 12 | import { ISelectionEventArgs } from '../drop-down/drop-down.common';
|
13 |
| -import { IgxToggleModule, IgxOverlayOutletDirective } from '../directives/toggle/toggle.directive'; |
| 13 | +import { IgxToggleModule } from '../directives/toggle/toggle.directive'; |
14 | 14 | import { configureTestSuite } from '../test-utils/configure-suite';
|
15 | 15 | import { HorizontalAlignment, VerticalAlignment, ConnectedPositioningStrategy, AbsoluteScrollStrategy } from '../services';
|
16 | 16 | import { IgxSelectModule } from './select.module';
|
17 |
| -import { wait } from '../test-utils/ui-interactions.spec'; |
18 | 17 |
|
19 | 18 | const CSS_CLASS_INPUT_GROUP = 'igx-input-group';
|
20 | 19 | const CSS_CLASS_INPUT = 'igx-input-group__input';
|
@@ -604,6 +603,32 @@ describe('igxSelect', () => {
|
604 | 603 | inputGroupWithRequiredAsterisk = fix.debugElement.query(By.css('.' + CSS_CLASS_INPUT_GROUP_REQUIRED));
|
605 | 604 | expect(inputGroupWithRequiredAsterisk).toBeDefined();
|
606 | 605 | }));
|
| 606 | + |
| 607 | + // Bug #6025 Select does not disable in reactive form |
| 608 | + it('Should disable when form is disabled', fakeAsync(() => { |
| 609 | + const fix = TestBed.createComponent(IgxSelectReactiveFormComponent); |
| 610 | + fix.detectChanges(); |
| 611 | + const formGroup: FormGroup = fix.componentInstance.reactiveForm; |
| 612 | + const selectComp = fix.componentInstance.select; |
| 613 | + const inputGroup = fix.debugElement.query(By.css('.' + CSS_CLASS_INPUT_GROUP)); |
| 614 | + |
| 615 | + inputGroup.nativeElement.click(); |
| 616 | + tick(); |
| 617 | + fix.detectChanges(); |
| 618 | + expect(selectComp.collapsed).toBeFalsy(); |
| 619 | + |
| 620 | + selectComp.close(); |
| 621 | + fix.detectChanges(); |
| 622 | + |
| 623 | + formGroup.disable(); |
| 624 | + tick(); |
| 625 | + fix.detectChanges(); |
| 626 | + |
| 627 | + inputGroup.nativeElement.click(); |
| 628 | + tick(); |
| 629 | + fix.detectChanges(); |
| 630 | + expect(selectComp.collapsed).toBeTruthy(); |
| 631 | + })); |
607 | 632 | });
|
608 | 633 | describe('Selection tests: ', () => {
|
609 | 634 | describe('Using simple select component', () => {
|
@@ -1181,70 +1206,70 @@ describe('igxSelect', () => {
|
1181 | 1206 | }));
|
1182 | 1207 |
|
1183 | 1208 | it('should populate the input with the specified selected item text @input, instead of the selected item element innerText',
|
1184 |
| - fakeAsync(() => { |
1185 |
| - let selectedItemIndex = 1; |
1186 |
| - const groupIndex = 0; |
1187 |
| - const groupElement = selectList.children[groupIndex]; |
1188 |
| - const itemElementToSelect = groupElement.children[selectedItemIndex].nativeElement; |
1189 |
| - |
1190 |
| - const checkInputValue = function () { |
1191 |
| - expect(select.selectedItem.text).toEqual(select.input.value); |
1192 |
| - expect(inputElement.nativeElement.value.toString().trim()).toEqual(select.selectedItem.text); |
1193 |
| - }; |
| 1209 | + fakeAsync(() => { |
| 1210 | + let selectedItemIndex = 1; |
| 1211 | + const groupIndex = 0; |
| 1212 | + const groupElement = selectList.children[groupIndex]; |
| 1213 | + const itemElementToSelect = groupElement.children[selectedItemIndex].nativeElement; |
| 1214 | + |
| 1215 | + const checkInputValue = function () { |
| 1216 | + expect(select.selectedItem.text).toEqual(select.input.value); |
| 1217 | + expect(inputElement.nativeElement.value.toString().trim()).toEqual(select.selectedItem.text); |
| 1218 | + }; |
1194 | 1219 |
|
1195 |
| - // There is not a selected item initially |
1196 |
| - const selectedItems = fixture.debugElement.queryAll(By.css('.' + CSS_CLASS_SELECTED_ITEM)); |
1197 |
| - expect(selectedItems.length).toEqual(0); |
1198 |
| - expect(select.value).toBeUndefined(); |
1199 |
| - expect(select.input.value).toEqual(''); |
1200 |
| - expect(inputElement.nativeElement.value).toEqual(''); |
| 1220 | + // There is not a selected item initially |
| 1221 | + const selectedItems = fixture.debugElement.queryAll(By.css('.' + CSS_CLASS_SELECTED_ITEM)); |
| 1222 | + expect(selectedItems.length).toEqual(0); |
| 1223 | + expect(select.value).toBeUndefined(); |
| 1224 | + expect(select.input.value).toEqual(''); |
| 1225 | + expect(inputElement.nativeElement.value).toEqual(''); |
1201 | 1226 |
|
1202 |
| - // Select item - mouse click |
1203 |
| - select.toggle(); |
1204 |
| - tick(); |
1205 |
| - fixture.detectChanges(); |
1206 |
| - itemElementToSelect.click(); |
1207 |
| - fixture.detectChanges(); |
1208 |
| - checkInputValue(); |
| 1227 | + // Select item - mouse click |
| 1228 | + select.toggle(); |
| 1229 | + tick(); |
| 1230 | + fixture.detectChanges(); |
| 1231 | + itemElementToSelect.click(); |
| 1232 | + fixture.detectChanges(); |
| 1233 | + checkInputValue(); |
1209 | 1234 |
|
1210 |
| - // Select item - selectItem method |
1211 |
| - selectedItemIndex = 2; |
1212 |
| - select.selectItem(select.items[selectedItemIndex]); |
1213 |
| - tick(); |
1214 |
| - fixture.detectChanges(); |
1215 |
| - select.toggle(); |
1216 |
| - tick(); |
1217 |
| - fixture.detectChanges(); |
1218 |
| - checkInputValue(); |
| 1235 | + // Select item - selectItem method |
| 1236 | + selectedItemIndex = 2; |
| 1237 | + select.selectItem(select.items[selectedItemIndex]); |
| 1238 | + tick(); |
| 1239 | + fixture.detectChanges(); |
| 1240 | + select.toggle(); |
| 1241 | + tick(); |
| 1242 | + fixture.detectChanges(); |
| 1243 | + checkInputValue(); |
1219 | 1244 |
|
1220 |
| - // Select item - item selected property |
1221 |
| - selectedItemIndex = 3; |
1222 |
| - select.items[selectedItemIndex].selected = true; |
1223 |
| - fixture.detectChanges(); |
1224 |
| - checkInputValue(); |
1225 |
| - })); |
| 1245 | + // Select item - item selected property |
| 1246 | + selectedItemIndex = 3; |
| 1247 | + select.items[selectedItemIndex].selected = true; |
| 1248 | + fixture.detectChanges(); |
| 1249 | + checkInputValue(); |
| 1250 | + })); |
1226 | 1251 |
|
1227 | 1252 | it('Should populate the input with the selected item element innerText, when text @Input is undefined(not set)',
|
1228 |
| - fakeAsync(() => { |
1229 |
| - const selectedItemIndex = 2; |
1230 |
| - // const groupIndex = 0; |
1231 |
| - // const groupElement = selectList.children[groupIndex]; |
1232 |
| - // const itemElementToSelect = groupElement.children[selectedItemIndex].nativeElement; |
1233 |
| - const expectedInputText = 'Paris star'; |
1234 |
| - |
1235 |
| - const checkInputValue = function () { |
1236 |
| - expect(select.selectedItem.itemText).toEqual(expectedInputText); |
1237 |
| - expect(select.selectedItem.itemText).toEqual(select.input.value); |
1238 |
| - expect(inputElement.nativeElement.value.toString().trim()).toEqual(select.selectedItem.itemText); |
1239 |
| - }; |
| 1253 | + fakeAsync(() => { |
| 1254 | + const selectedItemIndex = 2; |
| 1255 | + // const groupIndex = 0; |
| 1256 | + // const groupElement = selectList.children[groupIndex]; |
| 1257 | + // const itemElementToSelect = groupElement.children[selectedItemIndex].nativeElement; |
| 1258 | + const expectedInputText = 'Paris star'; |
| 1259 | + |
| 1260 | + const checkInputValue = function () { |
| 1261 | + expect(select.selectedItem.itemText).toEqual(expectedInputText); |
| 1262 | + expect(select.selectedItem.itemText).toEqual(select.input.value); |
| 1263 | + expect(inputElement.nativeElement.value.toString().trim()).toEqual(select.selectedItem.itemText); |
| 1264 | + }; |
1240 | 1265 |
|
1241 |
| - // Select item - no select-item text. Should set item;s element innerText as input value. |
1242 |
| - (select.items[selectedItemIndex] as IgxSelectItemComponent).text = undefined; |
1243 |
| - select.items[selectedItemIndex].selected = true; |
1244 |
| - fixture.detectChanges(); |
1245 |
| - tick(); |
1246 |
| - checkInputValue(); |
1247 |
| - })); |
| 1266 | + // Select item - no select-item text. Should set item;s element innerText as input value. |
| 1267 | + (select.items[selectedItemIndex] as IgxSelectItemComponent).text = undefined; |
| 1268 | + select.items[selectedItemIndex].selected = true; |
| 1269 | + fixture.detectChanges(); |
| 1270 | + tick(); |
| 1271 | + checkInputValue(); |
| 1272 | + })); |
1248 | 1273 | });
|
1249 | 1274 | });
|
1250 | 1275 | describe('Grouped items tests: ', () => {
|
|
0 commit comments