forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap-test.js
66 lines (61 loc) · 1.73 KB
/
bootstrap-test.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
// Chai plugins
require( 'chai' )
.use( require( 'dirty-chai' ) )
.use( require( 'sinon-chai' ) );
// Sinon plugins
const sinon = require( 'sinon' );
const sinonTest = require( 'sinon-test' );
sinon.test = sinonTest.configureTest( sinon );
sinon.testCase = sinonTest.configureTestCase( sinon );
// Fake DOM
const { JSDOM } = require( 'jsdom' );
const dom = new JSDOM( '', {
features: {
FetchExternalResources: false,
ProcessExternalResources: false,
SkipExternalResources: true,
},
} );
global.window = dom.window;
global.document = dom.window.document;
global.navigator = dom.window.navigator;
global.requestAnimationFrame = window.setTimeout;
// These are necessary to load TinyMCE successfully
global.URL = window.URL;
global.window.tinyMCEPreInit = {
// Without this, TinyMCE tries to determine its URL by looking at the
// <script> tag where it was loaded from, which of course fails here.
baseURL: 'about:blank',
};
global.window._wpDateSettings = {
formats: {
date: 'j F Y',
datetime: 'j F Y G \h i \m\i\n',
time: 'G \h i \m\i\n',
},
l10n: {
locale: 'en',
meridiem: {
am: 'am',
AM: 'AM',
pm: 'pm',
PM: 'PM',
},
months: [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
weekdays: [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
relative: {
future: '%s from now',
past: '%s ago',
},
},
timezone: {
offset: '-5',
string: 'America/New_York',
},
};
global.wp = global.wp || {};
global.wp.a11y = {
speak: () => {},
};