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

sui-select with optionTemplate fails unit tests #442

Open
jpsilv opened this issue Nov 29, 2019 · 0 comments
Open

sui-select with optionTemplate fails unit tests #442

jpsilv opened this issue Nov 29, 2019 · 0 comments

Comments

@jpsilv
Copy link

jpsilv commented Nov 29, 2019

Bug description:

Unit tests fail with:

TypeError: Cannot read property 'clear' of undefined
	    at SuiSelectBase.drawTemplate (node_modules/ng2-semantic-ui/dist/modules/select/classes/select-base.js:368:1)
	    at SuiSelectBase.initialiseRenderedOption (node_modules/ng2-semantic-ui/dist/modules/select/classes/select-base.js:299:1)
	    at SuiSelect.initialiseRenderedOption (node_modules/ng2-semantic-ui/dist/modules/select/components/select.js:99:1)
	    at node_modules/ng2-semantic-ui/dist/modules/select/classes/select-base.js:287:37

When testing an option change in sui-select with an optionTemplate.

Got something like:
HTML:

<ng-container>
     <ng-template let-option #optionTemplate>
        <span><i class="lock icon"></i>{{ option.name }}</span>
    </ng-template>
    <sui-select #dropdown
      id="dataPointSetSelector"
      class="{{ cssClass }}"
      labelField="name"
      [options]="options"
      [optionTemplate]="optionTemplate"
      [isSearchable]="false"
      (selectedOptionChange)="select($event)">
      <sui-select-option *ngFor="let o of dropdown.filteredOptions" [value]="o"></sui-select-option>
    </sui-select>
</ng-container>

spec.ts:

fit('test', fakeAsync(() => {
  MockNgRedux.getSelectorStub(['options']).next(options);
  fixture.detectChanges();

  const secondOption = fixture.debugElement.queryAll(By.css('sui-select-option'))[1].nativeElement;
  secondOption.click();
  fixture.detectChanges();
  tick(200);

  expect(spy.selectOptions).toHaveBeenCalledWith([options[1]], component.statePath);
}));

Version of Angular, ng2-semantic-ui, and Semantic UI:

Angular: 7.3.6

ng2-semantic-ui: 0.9.6

Semantic UI: not sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant