Files
NapCatQQ/.pnpm-store/v3/files/56/4d59a583952f659516092f791067791dfa3f4d8d018e47c49b86d2452253a880547407f8c1612e4bd84f34d98798a6e0bf7dd4e334e63b00668f087c303904
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

88 lines
1.9 KiB
Plaintext

import test from 'tape';
import JSXAttributeMock from '../../../../__mocks__/JSXAttributeMock';
import getImplicitRoleForInput from '../../../../src/util/implicitRoles/input';
test('isAbstractRole', (t) => {
t.test('works for buttons', (st) => {
st.equal(
getImplicitRoleForInput([JSXAttributeMock('type', 'button')]),
'button',
);
st.equal(
getImplicitRoleForInput([JSXAttributeMock('type', 'image')]),
'button',
);
st.equal(
getImplicitRoleForInput([JSXAttributeMock('type', 'reset')]),
'button',
);
st.equal(
getImplicitRoleForInput([JSXAttributeMock('type', 'submit')]),
'button',
);
st.end();
});
t.equal(
getImplicitRoleForInput([JSXAttributeMock('type', 'checkbox')]),
'checkbox',
'works for checkboxes',
);
t.equal(
getImplicitRoleForInput([JSXAttributeMock('type', 'radio')]),
'radio',
'works for radios',
);
t.equal(
getImplicitRoleForInput([JSXAttributeMock('type', 'range')]),
'slider',
'works for ranges',
);
t.test('works for textboxes', (st) => {
st.equal(
getImplicitRoleForInput([JSXAttributeMock('type', 'email')]),
'textbox',
);
st.equal(
getImplicitRoleForInput([JSXAttributeMock('type', 'password')]),
'textbox',
);
st.equal(
getImplicitRoleForInput([JSXAttributeMock('type', 'search')]),
'textbox',
);
st.equal(
getImplicitRoleForInput([JSXAttributeMock('type', 'tel')]),
'textbox',
);
st.equal(
getImplicitRoleForInput([JSXAttributeMock('type', 'url')]),
'textbox',
);
st.end();
});
t.equal(
getImplicitRoleForInput([JSXAttributeMock('type', '')]),
'textbox',
'works for the default case',
);
t.equal(
getImplicitRoleForInput([JSXAttributeMock('type', true)]),
'textbox',
'works for the true case',
);
t.end();
});