Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix select with autocomplete tests #3116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { Component, ElementRef, EventEmitter, Input, Output, QueryList, ViewChild, ViewChildren } from '@angular/core';
import { ComponentFixture, fakeAsync, flush, TestBed } from '@angular/core/testing';
import { ComponentFixture, discardPeriodicTasks, fakeAsync, flush, TestBed } from '@angular/core/testing';
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { RouterTestingModule } from '@angular/router/testing';
Expand Down Expand Up @@ -711,7 +711,7 @@ describe('Component: NbSelectComponent', () => {
}));
});

describe('NbSelectComponent - falsy values', () => {
describe('NbSelectWithAutocompleteComponent - falsy values', () => {
let fixture: ComponentFixture<NbSelectWithFalsyOptionValuesComponent>;
let testComponent: NbSelectWithFalsyOptionValuesComponent;
let select: NbSelectComponent;
Expand All @@ -736,6 +736,7 @@ describe('NbSelectComponent - falsy values', () => {

testComponent.noValueOption.onClick(eventMock);
fixture.detectChanges();
flush();

expect(select.selectionModel.length).toEqual(0);
}));
Expand All @@ -746,6 +747,7 @@ describe('NbSelectComponent - falsy values', () => {

testComponent.nullOption.onClick(eventMock);
fixture.detectChanges();
flush();

expect(select.selectionModel.length).toEqual(0);
}));
Expand All @@ -756,6 +758,7 @@ describe('NbSelectComponent - falsy values', () => {

testComponent.undefinedOption.onClick(eventMock);
fixture.detectChanges();
flush();

expect(select.selectionModel.length).toEqual(0);
}));
Expand All @@ -766,6 +769,7 @@ describe('NbSelectComponent - falsy values', () => {

testComponent.falseOption.onClick(eventMock);
fixture.detectChanges();
flush();

expect(select.selectionModel.length).toEqual(1);
}));
Expand All @@ -776,6 +780,7 @@ describe('NbSelectComponent - falsy values', () => {

testComponent.zeroOption.onClick(eventMock);
fixture.detectChanges();
flush();

expect(select.selectionModel.length).toEqual(1);
}));
Expand All @@ -786,6 +791,7 @@ describe('NbSelectComponent - falsy values', () => {

testComponent.emptyStringOption.onClick(eventMock);
fixture.detectChanges();
flush();

expect(select.selectionModel.length).toEqual(1);
}));
Expand All @@ -796,6 +802,7 @@ describe('NbSelectComponent - falsy values', () => {

testComponent.nanOption.onClick(eventMock);
fixture.detectChanges();
flush();

expect(select.selectionModel.length).toEqual(1);
}));
Expand Down Expand Up @@ -849,7 +856,7 @@ describe('NbSelectComponent - falsy values', () => {
}));
});

describe('NbSelectComponent - Triggers', () => {
describe('NbSelectWithAutocompleteComponent - Triggers', () => {
let fixture: ComponentFixture<BasicSelectTestComponent>;
let selectComponent: NbSelectComponent;
let triggerBuilderStub;
Expand Down Expand Up @@ -914,7 +921,7 @@ describe('NbSelectComponent - Triggers', () => {
}));
});

describe('NbSelectComponent - Key manager', () => {
describe('NbSelectWithAutocompleteComponent - Key manager', () => {
let fixture: ComponentFixture<BasicSelectTestComponent>;
let selectComponent: NbSelectComponent;
let tabOutStub: Subject<void>;
Expand Down Expand Up @@ -1247,8 +1254,8 @@ describe('NbSelect - dynamic options', () => {
<nb-layout-column>
<nb-select-with-autocomplete
[(ngModel)]="selectedValue"
[withOptionSearch]="true"
(optionSearchChange)="filterValue = $event"
[withOptionsAutocomplete]="true"
(optionsAutocompleteInputChange)="filterValue = $event"
(selectOpen)="isOpened = true"
(selectClose)="isOpened = false"
>
Expand Down Expand Up @@ -1289,7 +1296,7 @@ describe('NbSelect - experimental search', () => {
});

it("should update search input and don't emit filterChange when value of select is changed", fakeAsync(() => {
const searchInput = testComponent.selectComponent.optionSearchInput.nativeElement;
const searchInput = testComponent.selectComponent.optionsAutocompleteInput.nativeElement;

expect(searchInput.value).toEqual('');
expect(testComponent.filterValue).toEqual('');
Expand Down