Skip to content

Instantly share code, notes, and snippets.

@obsd
Last active January 30, 2020 20:09
Show Gist options
  • Save obsd/7906a74a2dc02551ec54cedaf71008f7 to your computer and use it in GitHub Desktop.
Save obsd/7906a74a2dc02551ec54cedaf71008f7 to your computer and use it in GitHub Desktop.
...
fixture = TestBed.createComponent(DatatableFiltersComponent); // component preprerations
component = fixture.debugElement.componentInstance;
component.filterOptions = createFilterOptions();
component.filtersState = [];
});
it('should create pill', async () => { // checking the simplest behaviour
const filterValue = ["a"];
const demoFilter = createFilter(EXAMPLE_FILTER_NAME, filterValue);
expect(component.pillsSubject.value.length).toEqual(0);
component.filtersState = [...component.currentFiltersState, demoFilter];
expect(component.pillsSubject.value.length).toEqual(demoFilter.values.length);
});
it('should create 2 pills of same filter', async () => { // we should have 2 search pills, one for each filter
const demoFilter = createFilter(EXAMPLE_FILTER_NAME, EXMAPLE_FILTER_VALUES);
expect(component.pillsSubject.value.length).toEqual(0);
component.filtersState = [...component.currentFiltersState, demoFilter];
expect(component.pillsSubject.value.length).toEqual(demoFilter.values.length);
});
...
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment