This repository was archived by the owner on Aug 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
/
Copy pathbootstrap.js
105 lines (95 loc) · 2.55 KB
/
bootstrap.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
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
100
101
102
103
104
105
// Run babel on tests to allow support for import/export statements in Node
require('@babel/register')
// Load JSDOM to mock the DOM in Node
// Set pretendToBeVisual to enable requestAnimationFrame
require('jsdom-global')(undefined, {
pretendToBeVisual: true,
url: 'https://www.test-overleaf.com/',
})
// workaround for "keys.js in jsdom-global doesn't include AbortController"
global.AbortController = window.AbortController
const path = require('path')
process.env.SHARELATEX_CONFIG = path.resolve(
__dirname,
'../../config/settings.webpack.js'
)
// Load sinon-chai assertions so expect(stubFn).to.have.been.calledWith('abc')
// has a nicer failure messages
const chai = require('chai')
chai.use(require('sinon-chai'))
chai.use(require('chai-as-promised'))
// Mock global settings
window.ExposedSettings = {
appName: 'Overleaf',
maxEntitiesPerProject: 10,
maxUploadSize: 5 * 1024 * 1024,
siteUrl: 'https://www.dev-overleaf.com',
hasLinkUrlFeature: true,
hasLinkedProjectFileFeature: true,
hasLinkedProjectOutputFileFeature: true,
textExtensions: [
'tex',
'latex',
'sty',
'cls',
'bst',
'bib',
'bibtex',
'txt',
'tikz',
'mtx',
'rtex',
'md',
'asy',
'latexmkrc',
'lbx',
'bbx',
'cbx',
'm',
'lco',
'dtx',
'ins',
'ist',
'def',
'clo',
'ldf',
'rmd',
'lua',
'gv',
'mf',
],
}
window.i18n = { currentLangCode: 'en' }
require('../../frontend/js/i18n')
const moment = require('moment')
moment.updateLocale('en', {
calendar: {
lastDay: '[Yesterday]',
sameDay: '[Today]',
nextDay: '[Tomorrow]',
lastWeek: 'ddd, Do MMM YY',
nextWeek: 'ddd, Do MMM YY',
sameElse: 'ddd, Do MMM YY',
},
})
let inMemoryLocalStorage = {}
Object.defineProperty(global, 'localStorage', {
value: {
// localStorage returns `null` when the item does not exist
getItem: key =>
inMemoryLocalStorage[key] !== undefined
? inMemoryLocalStorage[key]
: null,
setItem: (key, value) => (inMemoryLocalStorage[key] = value),
clear: () => (inMemoryLocalStorage = {}),
removeItem: key => delete inMemoryLocalStorage[key],
},
writable: true,
})
// node-fetch doesn't accept relative URL's: https://github.com/node-fetch/node-fetch/blob/master/docs/v2-LIMITS.md#known-differences
const fetch = require('node-fetch')
global.fetch = window.fetch = (url, ...options) =>
fetch(new URL(url, 'http://localhost'), ...options)
// ignore CSS files
const { addHook } = require('pirates')
addHook(() => '', { exts: ['.css'], ignoreNodeModules: false })