-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5508 from nextcloud-libraries/backport/5507/next
[next] fix(NcCheckboxRadioSwitch): Pass attrs to `input` if available
- Loading branch information
Showing
2 changed files
with
85 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
tests/unit/components/NcCheckboxRadioSwitch/checkbox.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import { mount, shallowMount } from '@vue/test-utils' | ||
import { describe, expect, it } from 'vitest' | ||
import NcCheckboxRadioSwitch from '../../../../src/components/NcCheckboxRadioSwitch/NcCheckboxRadioSwitch.vue' | ||
|
||
describe('NcCheckboxRadioSwitch', () => { | ||
it('sets text content', () => { | ||
const wrapper = mount(NcCheckboxRadioSwitch, { | ||
slots: { | ||
default: 'Test', | ||
}, | ||
}) | ||
|
||
expect(wrapper.text()).toContain('Test') | ||
}) | ||
|
||
it('forwards aria-invalid and aria-errormessage to input', () => { | ||
const wrapper = shallowMount(NcCheckboxRadioSwitch, { | ||
slots: { | ||
default: 'Test', | ||
}, | ||
attrs: { | ||
'aria-invalid': 'true', | ||
'aria-errormessage': 'id-test', | ||
}, | ||
}) | ||
|
||
const input = wrapper.find('input') | ||
expect(input.attributes('aria-invalid')).toBe('true') | ||
expect(input.attributes('aria-errormessage')).toBe('id-test') | ||
}) | ||
}) |