import { expect } from '@open-wc/testing' import { render } from 'lit' import { FilterSelectButtons } from '../src/filters/filter-select-buttons.js' /* * A select-buttons filter hands its options to the chips as given: the count after the name (how many rows a chip would * show) and the meaning on hover. Mapping an option to its display and value alone once dropped both. */ describe('select-buttons filter', () => { it('passes each option’s count and hint to its chip', async () => { const column: any = { name: 'state', record: {}, filter: { operator: 'in', options: [ { display: 'Draft', value: 'draft', count: 4, hint: 'not yet released' }, { display: 'Released', value: 'released', count: 0 } ] } } const host = document.createElement('div') document.body.appendChild(host) render(FilterSelectButtons(column, ['draft'], {} as any), host) const buttons = host.querySelector('ox-input-select-buttons') as any await buttons.updateComplete expect(buttons.options.map((one: any) => [one.count, one.hint])).to.deep.equal([ [4, 'not yet released'], [0, undefined] ]) /* The first chip is 「전체」 (several choices may be none) and has no count of its own. */ const chips = [...buttons.renderRoot.querySelectorAll('md-filter-chip:not([data-all])')] as HTMLElement[] expect(chips.map(chip => chip.querySelector('.count')?.textContent)).to.deep.equal(['4', '0']) host.remove() }) })