import '../../../fomantic/build/fomantic.js'; import {initGiteaFomantic} from '../fomantic.ts'; import {createElementFromHTML} from '../../utils/dom.ts'; import {hideScopedEmptyDividers} from './dropdown.ts'; initGiteaFomantic(); test('dropdown-item-literal-text-and-default-templates-untouched', () => { const defaultTemplates = {...$.fn.dropdown.settings.templates}; // a "choice" workflow_dispatch input can offer the string "false" as an option. // jQuery `.data()` would coerce `data-text="false"` to the boolean `false`, which then renders as empty text. const $dropdown = $(``).dropdown(); for (const value of ['1', '0', 'true', 'false']) { $dropdown.dropdown('set selected', value); expect($dropdown.dropdown('get text')).toEqual(value); expect($dropdown.dropdown('get value')).toEqual(value); } $dropdown.dropdown('change values', [{name: 'dynamic', value: 'dynamic'}]); expect($dropdown.closest('.ui.dropdown').find('[data-item-dynamic]').attr('role')).toEqual('menuitem'); expect($.fn.dropdown.settings.templates).toEqual(defaultTemplates); }); test('hideScopedEmptyDividers-simple', () => { const container = createElementFromHTML(`
a
b
`); hideScopedEmptyDividers(container); expect(container.innerHTML).toEqual(`
a
b
`); }); test('hideScopedEmptyDividers-items-all-filtered', () => { const container = createElementFromHTML(`
a
b
`); hideScopedEmptyDividers(container); expect(container.innerHTML).toEqual(`
a
b
`); }); test('hideScopedEmptyDividers-hide-last', () => { const container = createElementFromHTML(`
a
b
`); hideScopedEmptyDividers(container); expect(container.innerHTML).toEqual(`
a
b
`); }); test('hideScopedEmptyDividers-scoped-items', () => { const container = createElementFromHTML(`
a
b
c
`); hideScopedEmptyDividers(container); expect(container.innerHTML).toEqual(`
a
b
c
`); });