-
Notifications
You must be signed in to change notification settings - Fork 25
/
jest.init.ts
87 lines (77 loc) · 2.12 KB
/
jest.init.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { config } from "@vue/test-utils";
import VueClickAway from "vue3-click-away";
import { createI18n } from 'vue-i18n';
import { createStore } from 'vuex';
// Existing configuration
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: (query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
}),
});
// Mock window.scrollTo
Object.defineProperty(window, 'scrollTo', {
writable: true,
value: jest.fn(),
});
const InlineSvg = {
template: "<img />",
};
config.global.stubs = {
InlineSvg,
};
config.global.plugins = [VueClickAway];
// i18n configuration
const messages = {
en: {
generalInstructions: {
header: "General Instructions",
timerInfo: "This test has a timer.",
paletteInfo: "The question palette shows the status of the questions.",
},
answeringQuestion: {
title: "Answering a Question",
procedureForMCQ: "Follow these steps for MCQ questions.",
},
},
hi: {
generalInstructions: {
header: "सामान्य निर्देश",
timerInfo: "इस परीक्षा में एक टाइमर है।",
paletteInfo: "प्रश्न पैलेट प्रश्नों की स्थिति दिखाता है।",
},
answeringQuestion: {
title: "प्रश्न का उत्तर देना",
procedureForMCQ: "एमसीक्यू के लिए इन चरणों का पालन करें।",
},
},
};
const i18n = createI18n({
legacy: false,
locale: 'en',
fallbackLocale: 'en',
messages,
});
config.global.plugins.push(i18n);
// Vuex configuration
const store = createStore({
state: {
locale: "en", // Mock locale state
},
getters: {
locale: (state) => state.locale, // Mock locale getter
},
mutations: {
setLocale(state, locale) {
state.locale = locale;
}
},
});
config.global.plugins.push(store);