-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathjest.setup.js
More file actions
99 lines (86 loc) · 1.71 KB
/
Copy pathjest.setup.js
File metadata and controls
99 lines (86 loc) · 1.71 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
'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 {
constructor( title, namespace ) {
this.title = title;
this.namespace = namespace ? mw.config.get(
'wgFormattedNamespaces'
)[ namespace ] + ':' : '';
}
toString() {
return this.namespace + this.title;
}
getUrl() {
return '/wiki/' + this.toString();
}
}
class MessagePoster {
post() {
return Promise.resolve();
}
}
class Api {
get() {
return Promise.resolve( { pagetriagestats: { stats: '' } } );
}
saveOption() {
return Promise.resolve( true );
}
postWithToken() {
return Promise.resolve();
}
}
class Rest {
post() {
return Promise.resolve( {
'~2025-3939': {
revIps: {
5: '127.0.0.1'
}
}
} );
}
}
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.mw.Rest = Rest;
global.mw.message = function ( key ) {
return {
text: function () {
return `${ key }`;
},
escaped: function () {
return `${ key }`;
}
};
};
global.IntersectionObserver = IntersectionObserver;
global.mw.user.options = new mw.Map();