mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-11-06 15:40:01 +08:00
- vite 8、@vitejs/plugin-vue 6、vitest 5、happy-dom 21、@vue/test-utils 2.5、 typescript ~6.0.3、vue-tsc 3.3、unocss 66.11、unplugin-auto-import 21、 unplugin-vue-components 32、sass-embedded 1.105、playwright 1.64.1、storybook 10.6 - vite.config:去掉 defineModel 开关;Sass 改用 @use;esbuild.drop 换成 rolldown 的 dropConsole;__dirname 换成 import.meta.dirname;两处 alias 改为 resolve.tsconfigPaths - 删除 plugin-vue-jsx:三个 SFC 的 JSX 改写为 h() - 删除 preset-attributify:模板里的属性式工具类全部改回 class (含 space-y-*、text-*、line、i-carbon-* 等,不止 5 处 flex="~") - 删除 vite-plugin-pwa:改为静态 manifest.webmanifest + 自毁 sw.js(4.1 删除) - tsconfig:moduleResolution Bundler、去掉 baseUrl 与 JSX 配置, app 的 types 只留 vitest/globals - Storybook 10:addon-links + addon-docs,stories 改从 @storybook/vue3-vite 导入类型 - @intlify/unplugin-vue-i18n 0.11 -> 11.2.7(Vite 8 下旧版产物被 vite-json 再次解析而失败); 新版只产出 AST 文案,故打开 __INTLIFY_JIT_COMPILATION__,hasKey 识别 AST 叶子
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
import AbInput from '../ab-input.vue';
|
|
|
|
describe('ab-input', () => {
|
|
it('should bind v-model', async () => {
|
|
const wrapper = mount(AbInput, {
|
|
props: {
|
|
modelValue: 'abc',
|
|
'onUpdate:modelValue': (v: string | number) =>
|
|
wrapper.setProps({ modelValue: v }),
|
|
},
|
|
});
|
|
await wrapper.find('input').setValue('https://mikanani.me');
|
|
expect(wrapper.props('modelValue')).toBe('https://mikanani.me');
|
|
});
|
|
|
|
it('should apply the error class when error is set', () => {
|
|
const wrapper = mount(AbInput, {
|
|
props: { modelValue: '', error: true },
|
|
});
|
|
expect(wrapper.classes()).toContain('ab-input--error');
|
|
});
|
|
|
|
it('should clear the value via the clear button when clearable', async () => {
|
|
const wrapper = mount(AbInput, {
|
|
props: {
|
|
modelValue: 'abc',
|
|
clearable: true,
|
|
'onUpdate:modelValue': (v: string | number) =>
|
|
wrapper.setProps({ modelValue: v }),
|
|
},
|
|
});
|
|
await wrapper.find('.ab-input-clear').trigger('click');
|
|
expect(wrapper.props('modelValue')).toBe('');
|
|
});
|
|
|
|
it('should toggle password visibility', async () => {
|
|
const wrapper = mount(AbInput, {
|
|
props: { modelValue: 'secret', type: 'password' },
|
|
});
|
|
expect(wrapper.find('input').attributes('type')).toBe('password');
|
|
await wrapper.find('.ab-input-reveal').trigger('click');
|
|
expect(wrapper.find('input').attributes('type')).toBe('text');
|
|
});
|
|
|
|
it('should emit numbers for type=number', async () => {
|
|
const wrapper = mount(AbInput, {
|
|
props: { modelValue: 0, type: 'number' },
|
|
});
|
|
await wrapper.find('input').setValue('42');
|
|
expect(wrapper.emitted('update:modelValue')?.at(-1)).toEqual([42]);
|
|
});
|
|
});
|