2020-07-09 09:56:33 -04:00
|
|
|
// Run babel on tests to allow support for import/export statements in Node
|
|
|
|
require('@babel/register')
|
|
|
|
|
|
|
|
// Load JSDOM to mock the DOM in Node
|
2021-03-18 05:52:36 -04:00
|
|
|
// Set pretendToBeVisual to enable requestAnimationFrame
|
|
|
|
require('jsdom-global')(undefined, { pretendToBeVisual: true })
|
|
|
|
|
|
|
|
const path = require('path')
|
|
|
|
process.env.SHARELATEX_CONFIG = path.resolve(
|
|
|
|
__dirname,
|
|
|
|
'../../config/settings.webpack.coffee'
|
|
|
|
)
|
2020-07-09 09:56:33 -04:00
|
|
|
|
|
|
|
// 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'))
|
2021-02-05 09:01:37 -05:00
|
|
|
chai.use(require('chai-as-promised'))
|
2020-09-15 08:48:08 -04:00
|
|
|
|
2021-03-25 06:11:31 -04:00
|
|
|
// Mock global settings
|
|
|
|
window.ExposedSettings = {
|
|
|
|
appName: 'Overleaf',
|
|
|
|
maxEntitiesPerProject: 10,
|
|
|
|
maxUploadSize: 5 * 1024 * 1024
|
|
|
|
}
|
|
|
|
|
2020-09-15 08:48:08 -04:00
|
|
|
window.i18n = { currentLangCode: 'en' }
|
|
|
|
require('../../frontend/js/i18n')
|
2020-10-27 06:52:40 -04:00
|
|
|
|
|
|
|
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'
|
|
|
|
}
|
|
|
|
})
|
2020-11-24 06:58:08 -05:00
|
|
|
|
2021-01-07 09:22:40 -05:00
|
|
|
let inMemoryLocalStorage = {}
|
2021-02-09 10:39:44 -05:00
|
|
|
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
|
|
|
|
})
|
2021-01-07 09:22:40 -05:00
|
|
|
|
2020-11-24 06:58:08 -05:00
|
|
|
// 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 = (url, ...options) => fetch('http://localhost' + url, ...options)
|
2020-12-03 08:58:46 -05:00
|
|
|
|
2021-03-18 05:52:36 -04:00
|
|
|
// ignore CSS files
|
|
|
|
const { addHook } = require('pirates')
|
|
|
|
addHook(() => '', { exts: ['.css'], ignoreNodeModules: false })
|