-
Notifications
You must be signed in to change notification settings - Fork 4
/
jest.setup.js
61 lines (52 loc) · 1.15 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
/* global Backbone, $, mw */
// dependencies provided by ext.pageTriage.external
global.jQuery = require( 'jquery' );
global.$ = global.jQuery;
// enough jquery-ui for testing
global._ = require( './modules/external/underscore.js' );
global.Backbone = require( './modules/external/backbone.js' );
Backbone.setDomLibrary( $ );
// mediawiki
const mockMediaWiki = require( '@wikimedia/mw-node-qunit/src/mockMediaWiki.js' );
global.mw = mockMediaWiki();
global.mw.Map = Map;
global.mediaWiki = mw;
class Message {
text() {
return '<message>';
}
}
class Title {
}
class MessagePoster {
post() {
return Promise.resolve();
}
}
class Api {
get() {
return Promise.resolve( { pagetriagestats: { stats: '' } } );
}
saveOption() {
return Promise.resolve( true );
}
postWithToken() {
return Promise.resolve();
}
}
class IntersectionObserver {
observe() {
return null;
}
}
global.mw.Title = Title;
global.mw.Message = Message;
global.mw.messagePoster = {
factory: {
create: () => Promise.resolve( new MessagePoster() )
}
};
global.mw.Api = Api;
global.IntersectionObserver = IntersectionObserver;
global.mw.user.options = new mw.Map();