Skip to content

Commit 91a44e0

Browse files
authored
Merge pull request #85 from CodinGame/update-monaco
Catch up monaco-vscode-api and monaco
2 parents 6c49dad + 96eee89 commit 91a44e0

29 files changed

+16248
-24908
lines changed

FixJSDOMEnvironment.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const JSDOMEnvironment = require('jest-environment-jsdom').default
2+
3+
4+
class FixJSDOMEnvironment extends JSDOMEnvironment {
5+
constructor(...args) {
6+
super(...args);
7+
8+
// FIXME https://github.com/jsdom/jsdom/issues/3363
9+
this.global.structuredClone = structuredClone;
10+
}
11+
}
12+
13+
// https://github.com/facebook/jest/blob/v29.4.3/website/versioned_docs/version-29.4/Configuration.md#testenvironment-string
14+
module.exports = FixJSDOMEnvironment

babel.test.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ module.exports = {
22
plugins: [
33
["@babel/plugin-transform-modules-commonjs", {
44
importInterop: 'babel'
5-
}]
5+
}],
6+
"babel-plugin-transform-import-meta"
67
],
78
presets: [
89
"@babel/preset-env",

browserMock.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const fs = require('fs/promises')
2+
const { performance } = require('perf_hooks')
3+
const path = require('path')
24

35
Object.defineProperty(document, 'queryCommandSupported', {
46
value: jest.fn().mockImplementation(() => true),
@@ -19,20 +21,19 @@ Object.defineProperty(window, 'matchMedia', {
1921
});
2022

2123
Object.defineProperty(window, 'fetch', {
22-
value: jest.fn(async (path) => {
23-
24-
const content = await fs.readFile(path)
24+
value: jest.fn(async (url) => {
25+
const content = await fs.readFile(new URL(url).pathname)
2526
return {
2627
json: async () => JSON.stringify(JSON.parse(content.toString())),
27-
arrayBuffer: async () => content.buffer.slice(content.byteOffset, content.byteOffset + content.byteLength)
28+
arrayBuffer: async () => content.buffer.slice(content.byteOffset, content.byteOffset + content.byteLength),
29+
status: 200
2830
}
2931
})
3032
})
3133

3234
Object.defineProperty(URL, 'createObjectURL', {
3335
value: jest.fn((blob) => {
34-
35-
return null
36+
return 'blob:not-working'
3637
})
3738
})
3839

@@ -90,6 +91,9 @@ Object.defineProperty(window, 'TextEncoder', {
9091
Object.defineProperty(window, 'TextDecoder', {
9192
value: class TextDecoder {
9293
decode (octets) {
94+
if (octets == null) {
95+
return ''
96+
}
9397
var string = "";
9498
var i = 0;
9599
while (i < octets.length) {
@@ -130,4 +134,19 @@ Object.defineProperty(window, 'TextDecoder', {
130134

131135
Object.defineProperty(window, 'Buffer', {
132136
value: undefined
133-
})
137+
})
138+
139+
// Force override performance, for some reason the implementation is empty otherwise
140+
let _performance = performance
141+
Object.defineProperty(global, 'performance', {
142+
get () { return _performance },
143+
set (v) {
144+
// ignore
145+
}
146+
})
147+
148+
global.CSS = {
149+
escape: v => v
150+
}
151+
152+
Element.prototype.scrollIntoView = jest.fn();

jest/onig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = "vscode-oniguruma/release/onig.wasm"
1+
module.exports = "node_modules/vscode-oniguruma/release/onig.wasm"

0 commit comments

Comments
 (0)