forked from learningequality/studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.js
97 lines (81 loc) · 2.83 KB
/
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
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
import 'regenerator-runtime/runtime';
import * as Aphrodite from 'aphrodite';
import * as AphroditeNoImportant from 'aphrodite/no-important';
import Vue from 'vue';
import Vuetify from 'vuetify';
import VueRouter from 'vue-router';
import Vuex from 'vuex';
import KThemePlugin from 'kolibri-design-system/lib/KThemePlugin';
import 'shared/i18n/setup';
// Polyfill indexeddb
import 'fake-indexeddb/auto';
// Ponyfill webstreams
import {ReadableStream, WritableStream, TransformStream, CountQueuingStrategy} from 'web-streams-polyfill/ponyfill/es2018';
import jquery from 'jquery';
window.jQuery = window.$ = jquery;
window.ReadableStream = global.ReadableStream = ReadableStream;
window.WritableStream = global.WritableStream = WritableStream;
window.TransformStream = global.TransformStream = TransformStream;
window.CountQueuingStrategy = global.CountQueuingStrategy = CountQueuingStrategy;
import AnalyticsPlugin from 'shared/analytics/plugin';
import { setupSchema } from 'shared/data';
import * as resources from 'shared/data/resources';
import icons from 'shared/vuetify/icons';
import ActionLink from 'shared/views/ActionLink';
import { i18nSetup } from 'shared/i18n';
import { resetJestGlobal } from 'shared/utils/testing'
global.beforeEach(() => {
return new Promise(resolve => {
Aphrodite.StyleSheetTestUtils.suppressStyleInjection();
AphroditeNoImportant.StyleSheetTestUtils.suppressStyleInjection();
return process.nextTick(resolve);
});
});
global.afterEach(() => {
return new Promise(resolve => {
Aphrodite.StyleSheetTestUtils.clearBufferAndResumeStyleInjection();
AphroditeNoImportant.StyleSheetTestUtils.clearBufferAndResumeStyleInjection();
return process.nextTick(resolve);
});
});
window.storageBaseUrl = '/content/storage/';
Vue.use(VueRouter);
Vue.use(Vuex);
Vue.use(Vuetify, {
icons: icons(),
});
// Register kolibri-design-system plugin
Vue.use(KThemePlugin);
// Register analytics plugin with plain array
Vue.use(AnalyticsPlugin, { dataLayer: [] });
// Register global components
Vue.component('ActionLink', ActionLink);
i18nSetup(true);
Vue.config.silent = true;
Vue.config.devtools = false;
Vue.config.productionTip = false;
const csrf = global.document.createElement('input');
csrf.name = 'csrfmiddlewaretoken';
csrf.value = 'csrfmiddlewaretoken';
global.document.body.append(csrf);
global.document.body.setAttribute('data-app', true);
global.window.Urls = new Proxy(
{},
{
get(obj, prop) {
return () => prop;
},
}
);
Object.values(resources).forEach(resource => {
if (resource.fetchCollection) {
resource.fetchCollection = () => Promise.resolve([]);
}
if (resource.fetchModel) {
resource.fetchModel = () => Promise.resolve({});
}
});
jest.setTimeout(10000); // 10 sec
Object.defineProperty(window, 'scrollTo', { value: () => {}, writable: true });
resetJestGlobal();
setupSchema();