-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathjest.setup.js
41 lines (34 loc) · 1.02 KB
/
jest.setup.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
'use strict';
/* eslint-disable no-undef */
const { config } = require( '@vue/test-utils' );
const mockMediaWiki = require( '@wikimedia/mw-node-qunit/src/mockMediaWiki.js' );
// Mock Vue plugins in test suites
global.mw = mockMediaWiki();
global.mw.message = jest.fn( ( ...messageKeyAndParams ) => ( {
text: () => `(${ messageKeyAndParams.join( ', ' ) })`,
parse: () => `(${ messageKeyAndParams.join( ', ' ) })`
} ) );
global.mw.storage = {
session: {
get: jest.fn(),
set: jest.fn()
},
set: jest.fn()
};
global.mw.notify = jest.fn();
config.global.mocks = {
$i18n: ( ...messageKeyAndParams ) => ( {
text: () => '(' + messageKeyAndParams.join( ', ' ) + ')',
parse: () => '(' + messageKeyAndParams.join( ', ' ) + ')'
} )
};
config.global.directives = {
'i18n-html': ( el, binding ) => {
el.innerHTML = `${ binding.arg } (${ binding.value })`;
}
};
// Ignore all "teleport" behavior for the purpose of testing Dialog;
// see https://test-utils.vuejs.org/guide/advanced/teleport.html
config.global.stubs = {
teleport: true
};