Skip to content

Commit

Permalink
use input in test case
Browse files Browse the repository at this point in the history
  • Loading branch information
varnastadeus committed Mar 30, 2018
1 parent 2475448 commit a67a226
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/ng-select/ng-select.component.spec.ts
Expand Up @@ -635,14 +635,14 @@ describe('NgSelectComponent', function () {
`<ng-select [items]="cities"
bindLabel="name"
placeholder="select value"
[compareWith]="compareWith"
[(ngModel)]="selectedCity">
</ng-select>`);


const city = { name: 'Vilnius', id: 7, district: 'Ozo parkas' };
fixture.componentInstance.cities.push(city);
fixture.componentInstance.cities = [...fixture.componentInstance.cities];
fixture.componentInstance.select.compareWith = (a, b) => a.name === b.name && a.district === b.district;
fixture.componentInstance.selectedCity = { name: 'Vilnius', district: 'Ozo parkas' } as any;

tickAndDetectChanges(fixture);
Expand Down Expand Up @@ -2367,6 +2367,8 @@ class NgSelectTestCmp {
});
}

compareWith = (a, b) => a.name === b.name && a.district === b.district;

toggleVisible() {
this.visible = !this.visible;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ng-select/ng-select.component.ts
Expand Up @@ -49,7 +49,7 @@ import { ConsoleService } from './console.service';
export const NG_SELECT_DEFAULT_CONFIG = new InjectionToken<NgSelectConfig>('ng-select-default-options');
export type DropdownPosition = 'bottom' | 'top' | 'auto';
export type AddTagFn = ((term: string) => any | Promise<any>);
export type CompareWithFn = (o1: any, o2: any) => boolean;
export type CompareWithFn = (a: any, b: any) => boolean;

@Component({
selector: 'ng-select',
Expand Down Expand Up @@ -149,7 +149,7 @@ export class NgSelectComponent implements OnDestroy, OnChanges, AfterViewInit, C
private _primitive: boolean;

private readonly _destroy$ = new Subject<void>();
private _compareWith = (o1: any, o2: any) => o1 === o2;
private _compareWith = (a: any, b: any) => a === b;
private _onChange = (_: NgOption) => { };
private _onTouched = () => { };

Expand Down

0 comments on commit a67a226

Please sign in to comment.