2026-05-31 10:41:52 -05:00
|
|
|
import { mount } from "@vue/test-utils";
|
2025-06-20 00:09:12 +07:00
|
|
|
import { createI18n } from "vue-i18n";
|
2023-01-29 13:01:41 -09:00
|
|
|
|
|
|
|
|
function loadEnLocales() {
|
2025-06-20 00:09:12 +07:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
2023-01-29 13:01:41 -09:00
|
|
|
return require("../lang/messages/en-US.json") as Record<string, string>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function stubI18n() {
|
2025-06-20 00:09:12 +07:00
|
|
|
const i18n = createI18n({
|
2023-01-29 13:01:41 -09:00
|
|
|
locale: "en-US",
|
|
|
|
|
messages: {
|
|
|
|
|
"en-US": loadEnLocales(),
|
|
|
|
|
},
|
2025-06-20 00:09:12 +07:00
|
|
|
});
|
|
|
|
|
return i18n.global;
|
2023-01-29 13:01:41 -09:00
|
|
|
}
|
2026-05-31 10:41:52 -05:00
|
|
|
|
|
|
|
|
export const makeWrapper = <T>(setup: () => T) => {
|
|
|
|
|
const Wrapper = {
|
|
|
|
|
template: "<div />",
|
|
|
|
|
setup,
|
|
|
|
|
};
|
|
|
|
|
const { vm } = mount(Wrapper);
|
|
|
|
|
return vm as unknown as ReturnType<typeof Wrapper.setup>;
|
|
|
|
|
};
|