-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetupTests.js
67 lines (62 loc) · 1.17 KB
/
setupTests.js
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
global.WebSocket = require('ws');
const localStorageMock = (() => {
let store = {};
return {
getItem: function(key) {
return store[key];
},
setItem: function(key, value) {
store[key] = value.toString();
},
clear: function() {
store = {};
},
removeItem: function(key) {
delete store[key];
}
};
})();
const location = {
href: {
indexOf: jest.fn()
}
};
global.window = {
localStorage: localStorageMock,
location,
navigator: {
userAgent: {
indexOf: jest.fn(),
toLowerCase: jest.fn()
}
}
};
global.localStorage = localStorageMock;
global.location = location;
global.navigator = {
userAgent: 'node'
};
const Vue = require('vue');
const VueI18n = require('vue-i18n');
const zhEl = require('@/i18n/lib/locale/lang/zh-CN.js');
const enEl = require('@/i18n/lib/locale/lang/en.js');
const jaEl = require('@/i18n/lib/locale/lang/ja.js');
const messages = {
'zh-CN': {
...zhEl
},
'en-US': {
...enEl
},
'ja-JP': {
...jaEl
}
};
Vue.use(VueI18n);
const i18n = new VueI18n({
locale: 'zh-CN',
fallbackLocale: 'zh-CN',
messages
});
window['vm'] = {};
window['vm'].$i18n = i18n;