import { describe, expect, it } from 'vitest' import { mount } from '@vue/test-utils' import BaseCheckbox from '../../components/BaseCheckbox.vue' describe('BaseCheckbox indeterminate', () => { it('should set aria-checked="mixed" when indeterminate', () => { const wrapper = mount(BaseCheckbox, { props: { indeterminate: true } }) expect(wrapper.find('input').attributes('aria-checked')).toBe('mixed') }) it('should set the native indeterminate property when indeterminate', () => { const wrapper = mount(BaseCheckbox, { props: { indeterminate: true } }) expect((wrapper.find('input').element as HTMLInputElement).indeterminate).toBe(true) }) it('should render the dash mark when indeterminate', () => { const wrapper = mount(BaseCheckbox, { props: { indeterminate: true } }) expect(wrapper.find('.mint-checkbox__box--indeterminate').exists()).toBe(true) }) it('should omit aria-checked when not indeterminate', () => { const wrapper = mount(BaseCheckbox, { props: { modelValue: true } }) expect(wrapper.find('input').attributes('aria-checked')).toBeUndefined() }) it('should emit true when an indeterminate unchecked box is clicked', async () => { const wrapper = mount(BaseCheckbox, { props: { modelValue: false, indeterminate: true } }) await wrapper.find('input').setValue(true) expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([true]) }) }) describe('BaseCheckbox ariaLabel', () => { it('should name the native input from ariaLabel when there is no visible label', () => { const wrapper = mount(BaseCheckbox, { props: { ariaLabel: 'Select sample S1' } }) expect(wrapper.find('input').attributes('aria-label')).toBe('Select sample S1') }) it('should keep the aria-label off the root label when ariaLabel is set', () => { const wrapper = mount(BaseCheckbox, { props: { ariaLabel: 'Select sample S1' } }) expect(wrapper.attributes('aria-label')).toBeUndefined() }) })