-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupTests.js
More file actions
37 lines (32 loc) · 1.01 KB
/
Copy pathsetupTests.js
File metadata and controls
37 lines (32 loc) · 1.01 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
/**
* jest runner has been replaced from jsdom to jest-electron-runner
* https://github.com/facebook-atom/jest-electron-runner
* so there is no need for polyfill of web-components apis
* this file makes no sense and just be kept for reference
*/
global.Range = function Range() {}
/**
* there is a wrong implementation in
* https://stackoverflow.com/questions/42213522/mocking-document-createrange-for-jest
* watch out ❗
*/
const createContextualFragment = (html) => {
const template = document.createElement('template')
template.innerHTML = html
return template.content
}
Range.prototype.createContextualFragment = (html) =>
createContextualFragment(html)
// HACK: Polyfil that allows codemirror to render in a JSDOM env.
global.window.document.createRange = () => {
return {
setEnd: () => {},
setStart: () => {},
getBoundingClientRect: () => {
return { right: 0 }
},
getClientRects: () => [],
createContextualFragment
}
}
// require('electron').remote.getCurrentWindow().show()