@lvce-editor/shared-process 0.0.2 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/builtinCommands.json +367 -0
- package/config/colorTheme.json +98 -0
- package/config/defaultKeyBindings.json +649 -0
- package/config/defaultSettings.json +17 -0
- package/extensions/builtin.theme-slime/README.md +5 -0
- package/extensions/builtin.theme-slime/color-theme.json +205 -0
- package/extensions/builtin.theme-slime/extension.json +13 -0
- package/extensions/builtin.theme-slime/icon.png +0 -0
- package/package.json +3 -3
- package/src/parts/Env/Env.js +1 -1
- package/src/parts/Platform/Platform.js +7 -0
- package/src/parts/Preferences/Preferences.js +3 -6
- package/src/parts/Root/Root.js +1 -1
- package/test/Callback.test.js +0 -42
- package/test/ClipBoard.test.js +0 -105
- package/test/Credentials.test.js +0 -147
- package/test/Developer.test.js +0 -34
- package/test/Electron.test.js +0 -93
- package/test/Error.test.js +0 -16
- package/test/Exec.test.js +0 -25
- package/test/ExtensionHost.test.js +0 -127
- package/test/ExtensionHostColorTheme.test.js +0 -141
- package/test/ExtensionHostCommand.test.js +0 -27
- package/test/ExtensionHostCompletion.test.js +0 -45
- package/test/ExtensionHostDefinition.test.js +0 -35
- package/test/ExtensionHostDiagnostic.test.js +0 -23
- package/test/ExtensionHostFileSystem.test.js +0 -91
- package/test/ExtensionHostFormatting.test.js +0 -27
- package/test/ExtensionHostIconTheme.test.js +0 -73
- package/test/ExtensionHostLanguages.test.js +0 -212
- package/test/ExtensionHostOutput.test.js +0 -23
- package/test/ExtensionHostRename.test.js +0 -59
- package/test/ExtensionHostSemanticTokens.test.js +0 -26
- package/test/ExtensionHostTabCompletion.test.js +0 -35
- package/test/ExtensionHostTextDocument.test.js +0 -61
- package/test/ExtensionHostTypeDefinition.test.js +0 -35
- package/test/ExtensionHostWorkspace.test.js +0 -21
- package/test/ExtensionManagement.test.js +0 -408
- package/test/FileSystem.test.js +0 -294
- package/test/Json.test.js +0 -25
- package/test/Native.test.js +0 -31
- package/test/OutputChannel.test.js +0 -68
- package/test/Path.test.js +0 -17
- package/test/Platform.test.js +0 -61
- package/test/Preferences.test.js +0 -140
- package/test/Process.test.js +0 -9
- package/test/RgPath.test.js +0 -5
- package/test/Search.test.js +0 -45
- package/test/SearchFile.test.js +0 -80
- package/test/Terminal.test.js +0 -53
- package/test/Trash.test.js +0 -34
- package/test/WebSocketServer.test.js +0 -98
- package/test/fixture-search-1/index.html +0 -10
- package/test/fixture-search-file-1/fileA +0 -0
- package/test/fixture-search-file-1/fileB +0 -0
- package/test/fixture-search-file-1/nested/fileC +0 -0
package/test/Electron.test.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { jest } from '@jest/globals'
|
|
2
|
-
import * as Electron from '../src/parts/Electron/Electron.js'
|
|
3
|
-
|
|
4
|
-
test('toggleDevtools', () => {
|
|
5
|
-
Electron.state.send = jest.fn()
|
|
6
|
-
Electron.toggleDevtools()
|
|
7
|
-
expect(Electron.state.send).toHaveBeenCalledWith({
|
|
8
|
-
jsonrpc: '2.0',
|
|
9
|
-
method: 6523,
|
|
10
|
-
params: [],
|
|
11
|
-
})
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
test('windowMinimize', () => {
|
|
15
|
-
Electron.state.send = jest.fn()
|
|
16
|
-
Electron.windowMinimize()
|
|
17
|
-
expect(Electron.state.send).toHaveBeenCalledWith({
|
|
18
|
-
jsonrpc: '2.0',
|
|
19
|
-
method: 6521,
|
|
20
|
-
params: [],
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test('windowMaximize', () => {
|
|
25
|
-
Electron.state.send = jest.fn()
|
|
26
|
-
Electron.windowMaximize()
|
|
27
|
-
expect(Electron.state.send).toHaveBeenCalledWith({
|
|
28
|
-
jsonrpc: '2.0',
|
|
29
|
-
method: 6522,
|
|
30
|
-
params: [],
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
test('windowUnmaximize', () => {
|
|
35
|
-
Electron.state.send = jest.fn()
|
|
36
|
-
Electron.windowUnmaximize()
|
|
37
|
-
expect(Electron.state.send).toHaveBeenCalledWith({
|
|
38
|
-
jsonrpc: '2.0',
|
|
39
|
-
method: 6524,
|
|
40
|
-
params: [],
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
test('windowClose', () => {
|
|
45
|
-
Electron.state.send = jest.fn()
|
|
46
|
-
Electron.windowClose()
|
|
47
|
-
expect(Electron.state.send).toBeCalledWith({
|
|
48
|
-
jsonrpc: '2.0',
|
|
49
|
-
method: 6525,
|
|
50
|
-
params: [],
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
test('windowReload', () => {
|
|
55
|
-
Electron.state.send = jest.fn()
|
|
56
|
-
Electron.windowReload()
|
|
57
|
-
expect(Electron.state.send).toBeCalledWith({
|
|
58
|
-
jsonrpc: '2.0',
|
|
59
|
-
method: 6526,
|
|
60
|
-
params: [],
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
test('about', () => {
|
|
65
|
-
Electron.state.send = jest.fn()
|
|
66
|
-
Electron.about()
|
|
67
|
-
expect(Electron.state.send).toBeCalledWith({
|
|
68
|
-
jsonrpc: '2.0',
|
|
69
|
-
method: 20001,
|
|
70
|
-
params: [],
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
test('showOpenDialog', () => {
|
|
75
|
-
Electron.state.send = jest.fn()
|
|
76
|
-
Electron.showOpenDialog()
|
|
77
|
-
expect(Electron.state.send).toBeCalledWith({
|
|
78
|
-
jsonrpc: '2.0',
|
|
79
|
-
method: 20100,
|
|
80
|
-
params: [],
|
|
81
|
-
id: expect.any(Number),
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
test('crashMainProcess', () => {
|
|
86
|
-
Electron.state.send = jest.fn()
|
|
87
|
-
Electron.crashMainProcess()
|
|
88
|
-
expect(Electron.state.send).toBeCalledWith({
|
|
89
|
-
jsonrpc: '2.0',
|
|
90
|
-
method: 7723,
|
|
91
|
-
params: [],
|
|
92
|
-
})
|
|
93
|
-
})
|
package/test/Error.test.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as Error from '../src/parts/Error/Error.js'
|
|
2
|
-
|
|
3
|
-
// TODO don't shim global Error object
|
|
4
|
-
|
|
5
|
-
// TODO
|
|
6
|
-
test('OperationalError', () => {
|
|
7
|
-
const error = globalThis.Error('enoent: no such file')
|
|
8
|
-
const operationalError = new Error.OperationalError({
|
|
9
|
-
cause: error,
|
|
10
|
-
code: 'E_FAILED_TO_READ_FILE',
|
|
11
|
-
message: 'Failed to read file',
|
|
12
|
-
})
|
|
13
|
-
expect(operationalError.toString()).toBe(
|
|
14
|
-
'OperationalError: Failed to read file: enoent: no such file'
|
|
15
|
-
)
|
|
16
|
-
})
|
package/test/Exec.test.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as Exec from '../src/parts/Exec/Exec.js'
|
|
2
|
-
|
|
3
|
-
test('exec - stdout', async () => {
|
|
4
|
-
expect(
|
|
5
|
-
await Exec.exec('node', ['-e', "process.stdout.write('a')"], {})
|
|
6
|
-
).toEqual({
|
|
7
|
-
stderr: '',
|
|
8
|
-
stdout: 'a',
|
|
9
|
-
})
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
test('exec - stderr', async () => {
|
|
13
|
-
expect(
|
|
14
|
-
await Exec.exec('node', ['-e', "process.stderr.write('b')"], {})
|
|
15
|
-
).toEqual({
|
|
16
|
-
stderr: 'b',
|
|
17
|
-
stdout: '',
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
test('exec - error', async () => {
|
|
22
|
-
await expect(Exec.exec('node', ['-e', 'oops'], {})).rejects.toThrowError(
|
|
23
|
-
'Command failed with exit code 1: node -e oops'
|
|
24
|
-
)
|
|
25
|
-
})
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { mkdir, mkdtemp, writeFile } from 'node:fs/promises'
|
|
2
|
-
import { tmpdir } from 'node:os'
|
|
3
|
-
import { join } from 'node:path'
|
|
4
|
-
import * as ExtensionHost from '../src/parts/ExtensionHost/ExtensionHost.js'
|
|
5
|
-
import * as ExtensionManagement from '../src/parts/ExtensionManagement/ExtensionManagement.js'
|
|
6
|
-
import * as Platform from '../src/parts/Platform/Platform.js'
|
|
7
|
-
|
|
8
|
-
const getTmpDir = () => {
|
|
9
|
-
return mkdtemp(join(tmpdir(), 'foo-'))
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
test.skip('start / stop', async () => {
|
|
13
|
-
await ExtensionHost.start()
|
|
14
|
-
ExtensionHost.stop()
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
// TODO test with mock extensions
|
|
18
|
-
test.skip('activateAll', async () => {
|
|
19
|
-
const tmpDir1 = await getTmpDir()
|
|
20
|
-
const tmpDir2 = await getTmpDir()
|
|
21
|
-
ExtensionManagement.state.builtinExtensionsPath = tmpDir1
|
|
22
|
-
ExtensionManagement.state.extensionPath = tmpDir2
|
|
23
|
-
await ExtensionHost.start()
|
|
24
|
-
await ExtensionHost.activateAll()
|
|
25
|
-
await ExtensionHost.stop()
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
test('start - error - path not found', async () => {
|
|
29
|
-
Platform.state.getExtensionHostPath = () => {
|
|
30
|
-
return '/test'
|
|
31
|
-
}
|
|
32
|
-
const socket = {
|
|
33
|
-
on() {},
|
|
34
|
-
}
|
|
35
|
-
await expect(ExtensionHost.start(socket)).rejects.toThrowError(
|
|
36
|
-
new Error(
|
|
37
|
-
'Failed to start extension host: Extension Host exited with code 1'
|
|
38
|
-
)
|
|
39
|
-
)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
test('start - error - path is a directory', async () => {
|
|
43
|
-
const tmpDir = await getTmpDir()
|
|
44
|
-
Platform.state.getExtensionHostPath = () => {
|
|
45
|
-
return tmpDir
|
|
46
|
-
}
|
|
47
|
-
const socket = {
|
|
48
|
-
on() {},
|
|
49
|
-
}
|
|
50
|
-
await mkdir(tmpDir, { recursive: true })
|
|
51
|
-
// TODO error message should include stderr of extension host
|
|
52
|
-
await expect(ExtensionHost.start(socket)).rejects.toThrowError(
|
|
53
|
-
new Error(
|
|
54
|
-
'Failed to start extension host: Extension Host exited with code 1'
|
|
55
|
-
)
|
|
56
|
-
)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
test('start - error - syntax error', async () => {
|
|
60
|
-
const tmpDir = await getTmpDir()
|
|
61
|
-
const extensionHostPath = join(tmpDir, 'extensionHost.js')
|
|
62
|
-
await writeFile(extensionHostPath, '...')
|
|
63
|
-
Platform.state.getExtensionHostPath = () => {
|
|
64
|
-
return extensionHostPath
|
|
65
|
-
}
|
|
66
|
-
const socket = {
|
|
67
|
-
on() {},
|
|
68
|
-
}
|
|
69
|
-
// TODO error message should include stderr of extension host: SyntaxError: Unexpected end of input
|
|
70
|
-
await expect(ExtensionHost.start(socket)).rejects.toThrowError(
|
|
71
|
-
new Error(
|
|
72
|
-
'Failed to start extension host: Extension Host exited with code 1'
|
|
73
|
-
)
|
|
74
|
-
)
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
test('start - error - uncaught exception', async () => {
|
|
78
|
-
const tmpDir = await getTmpDir()
|
|
79
|
-
const extensionHostPath = join(tmpDir, 'extensionHost.js')
|
|
80
|
-
await writeFile(extensionHostPath, "throw new Error('oops')")
|
|
81
|
-
Platform.state.getExtensionHostPath = () => {
|
|
82
|
-
return extensionHostPath
|
|
83
|
-
}
|
|
84
|
-
const socket = {
|
|
85
|
-
on() {},
|
|
86
|
-
}
|
|
87
|
-
// TODO error message should include stderr of extension host: SyntaxError: Unexpected end of input
|
|
88
|
-
await expect(ExtensionHost.start(socket)).rejects.toThrowError(
|
|
89
|
-
new Error(
|
|
90
|
-
'Failed to start extension host: Extension Host exited with code 1'
|
|
91
|
-
)
|
|
92
|
-
)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
test('start - error - custom exit code', async () => {
|
|
96
|
-
const tmpDir = await getTmpDir()
|
|
97
|
-
const extensionHostPath = join(tmpDir, 'extensionHost.js')
|
|
98
|
-
await writeFile(extensionHostPath, 'process.exit(123)')
|
|
99
|
-
Platform.state.getExtensionHostPath = () => {
|
|
100
|
-
return extensionHostPath
|
|
101
|
-
}
|
|
102
|
-
const socket = {
|
|
103
|
-
on() {},
|
|
104
|
-
}
|
|
105
|
-
await expect(ExtensionHost.start(socket)).rejects.toThrowError(
|
|
106
|
-
new Error(
|
|
107
|
-
'Failed to start extension host: Extension Host exited with code 123'
|
|
108
|
-
)
|
|
109
|
-
)
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
test('start - child process should be closed when socket immediately is closed', async () => {
|
|
113
|
-
const tmpDir = await getTmpDir()
|
|
114
|
-
const extensionHostPath = join(tmpDir, 'extensionHost.js')
|
|
115
|
-
await writeFile(extensionHostPath, 'process.on(`message`, ()=>{})')
|
|
116
|
-
Platform.state.getExtensionHostPath = () => {
|
|
117
|
-
return extensionHostPath
|
|
118
|
-
}
|
|
119
|
-
const socket = {
|
|
120
|
-
on(event, listener) {
|
|
121
|
-
if (event === 'close') {
|
|
122
|
-
listener()
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
}
|
|
126
|
-
await ExtensionHost.start(socket)
|
|
127
|
-
})
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { mkdir, mkdtemp, writeFile } from 'node:fs/promises'
|
|
2
|
-
import { tmpdir } from 'node:os'
|
|
3
|
-
import { dirname, join } from 'node:path'
|
|
4
|
-
import * as ExtensionHostColorTheme from '../src/parts/ExtensionHost/ExtensionHostColorTheme.js'
|
|
5
|
-
import * as Platform from '../src/parts/Platform/Platform.js'
|
|
6
|
-
import * as ExtensionManagement from '../src/parts/ExtensionManagement/ExtensionManagement.js'
|
|
7
|
-
import * as JsonFile from '../src/parts/JsonFile/JsonFile.js'
|
|
8
|
-
|
|
9
|
-
const getTmpDir = () => {
|
|
10
|
-
return mkdtemp(join(tmpdir(), 'foo-'))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
test('getColorThemeNames - empty', async () => {
|
|
14
|
-
const tmpDir = await getTmpDir()
|
|
15
|
-
Platform.state.getExtensionsPath = () => {
|
|
16
|
-
return tmpDir
|
|
17
|
-
}
|
|
18
|
-
Platform.state.getBuiltinExtensionsPath = () => {
|
|
19
|
-
return tmpDir
|
|
20
|
-
}
|
|
21
|
-
expect(await ExtensionHostColorTheme.getColorThemes()).toEqual([])
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test.skip('getColorThemeJson - theme id contains number', async () => {
|
|
25
|
-
const tmpDir = await getTmpDir()
|
|
26
|
-
ExtensionManagement.state.getThemeExtensions = async () => {
|
|
27
|
-
return [
|
|
28
|
-
{
|
|
29
|
-
status: 'fulfilled',
|
|
30
|
-
id: 'builtin.test-cobalt2',
|
|
31
|
-
colorThemes: [
|
|
32
|
-
{
|
|
33
|
-
id: 'cobalt2',
|
|
34
|
-
label: 'Cobalt2 Theme',
|
|
35
|
-
path: 'color-theme.json',
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
path: join(tmpDir, 'builtin.theme-cobalt-2'),
|
|
39
|
-
},
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
const colorThemePath = join(
|
|
43
|
-
tmpDir,
|
|
44
|
-
'builtin.theme-cobalt2',
|
|
45
|
-
'color-theme.json'
|
|
46
|
-
)
|
|
47
|
-
await mkdir(dirname(colorThemePath), { recursive: true })
|
|
48
|
-
await writeFile(colorThemePath, '{}')
|
|
49
|
-
expect(await ExtensionHostColorTheme.getColorThemeJson('cobalt2')).toEqual({})
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
test('getColorThemeJson - invalid json', async () => {
|
|
53
|
-
const tmpDir = await getTmpDir()
|
|
54
|
-
Platform.state.getBuiltinExtensionsPath = () => {
|
|
55
|
-
return tmpDir
|
|
56
|
-
}
|
|
57
|
-
await JsonFile.writeJson(
|
|
58
|
-
join(tmpDir, 'builtin.theme-test', 'extension.json'),
|
|
59
|
-
{
|
|
60
|
-
id: 'builtin.test-theme',
|
|
61
|
-
colorThemes: [
|
|
62
|
-
{
|
|
63
|
-
id: 'test-theme',
|
|
64
|
-
label: 'Test Theme',
|
|
65
|
-
path: 'color-theme.json',
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
path: tmpDir,
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
const colorThemePath = join(tmpDir, 'builtin.theme-test', 'color-theme.json')
|
|
72
|
-
await writeFile(colorThemePath, '{ 1 }')
|
|
73
|
-
await expect(
|
|
74
|
-
ExtensionHostColorTheme.getColorThemeJson('test-theme')
|
|
75
|
-
).rejects.toThrowError(
|
|
76
|
-
'Failed to load color theme "test-theme": Unexpected number in JSON at position 2 while parsing \'{ 1 }\''
|
|
77
|
-
)
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
test('getColorThemeJson - wrong/invalid path', async () => {
|
|
81
|
-
const tmpDir = await getTmpDir()
|
|
82
|
-
Platform.state.getBuiltinExtensionsPath = () => {
|
|
83
|
-
return tmpDir
|
|
84
|
-
}
|
|
85
|
-
await JsonFile.writeJson(
|
|
86
|
-
join(tmpDir, 'builtin.theme-test', 'extension.json'),
|
|
87
|
-
{
|
|
88
|
-
id: 'builtin.theme-test',
|
|
89
|
-
colorThemes: [
|
|
90
|
-
{
|
|
91
|
-
id: 'test-theme',
|
|
92
|
-
label: 'Test Theme',
|
|
93
|
-
path: 'color-theme.json',
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
path: tmpDir,
|
|
97
|
-
}
|
|
98
|
-
)
|
|
99
|
-
const colorThemePath = join(tmpDir, 'builtin.theme-test', 'color-theme.json')
|
|
100
|
-
await expect(
|
|
101
|
-
ExtensionHostColorTheme.getColorThemeJson('test-theme')
|
|
102
|
-
).rejects.toThrowError(
|
|
103
|
-
`Failed to load color theme "test-theme": ENOENT: no such file or directory, open '${colorThemePath}'`
|
|
104
|
-
)
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
test('getColorThemes', async () => {
|
|
108
|
-
ExtensionManagement.state.getExtensions = async () => {
|
|
109
|
-
return [
|
|
110
|
-
{
|
|
111
|
-
status: 'fulfilled',
|
|
112
|
-
id: 'builtin.theme-slime',
|
|
113
|
-
colorThemes: [
|
|
114
|
-
{
|
|
115
|
-
id: 'slime',
|
|
116
|
-
label: 'Slime',
|
|
117
|
-
path: 'color-theme.json',
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
path: '/test',
|
|
121
|
-
},
|
|
122
|
-
]
|
|
123
|
-
}
|
|
124
|
-
expect(await ExtensionHostColorTheme.getColorThemes()).toEqual([
|
|
125
|
-
{
|
|
126
|
-
id: 'slime',
|
|
127
|
-
label: 'Slime',
|
|
128
|
-
path: 'color-theme.json',
|
|
129
|
-
},
|
|
130
|
-
])
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
test.skip('getColorThemeJson - not found', async () => {
|
|
134
|
-
ExtensionHost.state.builtinExtensions = []
|
|
135
|
-
ExtensionHost.state.installedExtensions = []
|
|
136
|
-
await expect(
|
|
137
|
-
ExtensionHost.getColorThemeJson('test-theme')
|
|
138
|
-
).rejects.toThrowError(
|
|
139
|
-
'Color theme "test-theme" not found in extensions folder'
|
|
140
|
-
)
|
|
141
|
-
})
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as ExtensionHostCommand from '../src/parts/ExtensionHost/ExtensionHostCommand.js'
|
|
2
|
-
|
|
3
|
-
test('executeCommand', async () => {
|
|
4
|
-
const fakeExtensionHost = {
|
|
5
|
-
invoke(method, ...params) {
|
|
6
|
-
return {
|
|
7
|
-
params,
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
|
-
}
|
|
11
|
-
expect(
|
|
12
|
-
await ExtensionHostCommand.executeCommand(fakeExtensionHost, 1, 2, 3)
|
|
13
|
-
).toEqual({
|
|
14
|
-
params: [1, 2, 3],
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('executeCommand - error', async () => {
|
|
19
|
-
const fakeExtensionHost = {
|
|
20
|
-
invoke() {
|
|
21
|
-
throw new TypeError('x is not a function')
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
await expect(
|
|
25
|
-
ExtensionHostCommand.executeCommand(fakeExtensionHost)
|
|
26
|
-
).rejects.toThrowError(new TypeError('x is not a function'))
|
|
27
|
-
})
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as ExtensionHostCompletion from '../src/parts/ExtensionHost/ExtensionHostCompletion.js'
|
|
2
|
-
|
|
3
|
-
test('executeCompletionProvider', async () => {
|
|
4
|
-
const fakeExtensionHost = {
|
|
5
|
-
invoke() {
|
|
6
|
-
return [
|
|
7
|
-
{
|
|
8
|
-
label: 'Option A',
|
|
9
|
-
snippet: 'Option A',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
label: 'Option B',
|
|
13
|
-
snippet: 'Option B',
|
|
14
|
-
},
|
|
15
|
-
]
|
|
16
|
-
},
|
|
17
|
-
}
|
|
18
|
-
expect(
|
|
19
|
-
await ExtensionHostCompletion.executeCompletionProvider(
|
|
20
|
-
fakeExtensionHost,
|
|
21
|
-
0,
|
|
22
|
-
0
|
|
23
|
-
)
|
|
24
|
-
).toEqual([
|
|
25
|
-
{
|
|
26
|
-
label: 'Option A',
|
|
27
|
-
snippet: 'Option A',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
label: 'Option B',
|
|
31
|
-
snippet: 'Option B',
|
|
32
|
-
},
|
|
33
|
-
])
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
test('executeCompletionProvider - error', async () => {
|
|
37
|
-
const fakeExtensionHost = {
|
|
38
|
-
invoke() {
|
|
39
|
-
throw new TypeError('x is not a function')
|
|
40
|
-
},
|
|
41
|
-
}
|
|
42
|
-
await expect(
|
|
43
|
-
ExtensionHostCompletion.executeCompletionProvider(fakeExtensionHost)
|
|
44
|
-
).rejects.toThrowError(new TypeError('x is not a function'))
|
|
45
|
-
})
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as ExtensionHostDefinition from '../src/parts/ExtensionHost/ExtensionHostDefinition.js'
|
|
2
|
-
|
|
3
|
-
test('executeDefinitionProvider', async () => {
|
|
4
|
-
const fakeExtensionHost = {
|
|
5
|
-
invoke() {
|
|
6
|
-
return {
|
|
7
|
-
uri: '/test/file.txt',
|
|
8
|
-
startOffset: 0,
|
|
9
|
-
endOffset: 0,
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
}
|
|
13
|
-
expect(
|
|
14
|
-
await ExtensionHostDefinition.executeDefinitionProvider(
|
|
15
|
-
fakeExtensionHost,
|
|
16
|
-
0,
|
|
17
|
-
0
|
|
18
|
-
)
|
|
19
|
-
).toEqual({
|
|
20
|
-
uri: '/test/file.txt',
|
|
21
|
-
startOffset: 0,
|
|
22
|
-
endOffset: 0,
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
test('executeDefinitionProvider - error', async () => {
|
|
27
|
-
const fakeExtensionHost = {
|
|
28
|
-
invoke() {
|
|
29
|
-
throw new TypeError('x is not a function')
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
await expect(
|
|
33
|
-
ExtensionHostDefinition.executeDefinitionProvider(fakeExtensionHost)
|
|
34
|
-
).rejects.toThrowError(new TypeError('x is not a function'))
|
|
35
|
-
})
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as ExtensionHostDiagnostic from '../src/parts/ExtensionHost/ExtensionHostDiagnostic.js'
|
|
2
|
-
|
|
3
|
-
test('executeDiagnosticProvider - empty', async () => {
|
|
4
|
-
const fakeExtensionHost = {
|
|
5
|
-
invoke() {
|
|
6
|
-
return []
|
|
7
|
-
},
|
|
8
|
-
}
|
|
9
|
-
expect(
|
|
10
|
-
await ExtensionHostDiagnostic.executeDiagnosticProvider(fakeExtensionHost)
|
|
11
|
-
).toEqual([])
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
test('executeDiagnosticProvider - error', async () => {
|
|
15
|
-
const fakeExtensionHost = {
|
|
16
|
-
invoke() {
|
|
17
|
-
throw new TypeError('x is not a function')
|
|
18
|
-
},
|
|
19
|
-
}
|
|
20
|
-
await expect(
|
|
21
|
-
ExtensionHostDiagnostic.executeDiagnosticProvider(fakeExtensionHost, 0)
|
|
22
|
-
).rejects.toThrowError(new TypeError('x is not a function'))
|
|
23
|
-
})
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import * as ExtensionHostFileSystem from '../src/parts/ExtensionHost/ExtensionHostFileSystem.js'
|
|
2
|
-
|
|
3
|
-
test('readFile', async () => {
|
|
4
|
-
const fakeExtensionHost = {
|
|
5
|
-
async invoke() {
|
|
6
|
-
return ''
|
|
7
|
-
},
|
|
8
|
-
}
|
|
9
|
-
expect(
|
|
10
|
-
await ExtensionHostFileSystem.readFile(
|
|
11
|
-
fakeExtensionHost,
|
|
12
|
-
'/test',
|
|
13
|
-
'/test/file.txt'
|
|
14
|
-
)
|
|
15
|
-
).toBe('')
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('readFile - error', async () => {
|
|
19
|
-
const fakeExtensionHost = {
|
|
20
|
-
async invoke() {
|
|
21
|
-
throw new TypeError('x is not a function')
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
await expect(
|
|
25
|
-
ExtensionHostFileSystem.readFile(
|
|
26
|
-
fakeExtensionHost,
|
|
27
|
-
'test',
|
|
28
|
-
'/test/file.txt'
|
|
29
|
-
)
|
|
30
|
-
).rejects.toThrowError(new TypeError('x is not a function'))
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
test('writeFile', async () => {
|
|
34
|
-
const fakeExtensionHost = {
|
|
35
|
-
async invoke() {},
|
|
36
|
-
}
|
|
37
|
-
expect(
|
|
38
|
-
await ExtensionHostFileSystem.writeFile(
|
|
39
|
-
fakeExtensionHost,
|
|
40
|
-
'/test',
|
|
41
|
-
'/test/file.txt',
|
|
42
|
-
''
|
|
43
|
-
)
|
|
44
|
-
).toBeUndefined()
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test('writeFile - error', async () => {
|
|
48
|
-
const fakeExtensionHost = {
|
|
49
|
-
async invoke() {
|
|
50
|
-
throw new TypeError('x is not a function')
|
|
51
|
-
},
|
|
52
|
-
}
|
|
53
|
-
await expect(
|
|
54
|
-
ExtensionHostFileSystem.writeFile(
|
|
55
|
-
fakeExtensionHost,
|
|
56
|
-
'test',
|
|
57
|
-
'/test/file.txt',
|
|
58
|
-
''
|
|
59
|
-
)
|
|
60
|
-
).rejects.toThrowError(new TypeError('x is not a function'))
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
test('readDirWithFileTypes', async () => {
|
|
64
|
-
const fakeExtensionHost = {
|
|
65
|
-
async invoke() {
|
|
66
|
-
return []
|
|
67
|
-
},
|
|
68
|
-
}
|
|
69
|
-
expect(
|
|
70
|
-
await ExtensionHostFileSystem.readDirWithFileTypes(
|
|
71
|
-
fakeExtensionHost,
|
|
72
|
-
'test',
|
|
73
|
-
'/test'
|
|
74
|
-
)
|
|
75
|
-
).toEqual([])
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
test('readDirWithFileTypes - error', async () => {
|
|
79
|
-
const fakeExtensionHost = {
|
|
80
|
-
async invoke() {
|
|
81
|
-
throw new TypeError('x is not a function')
|
|
82
|
-
},
|
|
83
|
-
}
|
|
84
|
-
await expect(
|
|
85
|
-
ExtensionHostFileSystem.readDirWithFileTypes(
|
|
86
|
-
fakeExtensionHost,
|
|
87
|
-
'test',
|
|
88
|
-
'/test'
|
|
89
|
-
)
|
|
90
|
-
).rejects.toThrowError(new TypeError('x is not a function'))
|
|
91
|
-
})
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as ExtensionHostFormatting from '../src/parts/ExtensionHost/ExtensionHostFormatting.js'
|
|
2
|
-
|
|
3
|
-
test('executeFormattingProvider', async () => {
|
|
4
|
-
const fakeExtensionHost = {
|
|
5
|
-
invoke() {
|
|
6
|
-
return ''
|
|
7
|
-
},
|
|
8
|
-
}
|
|
9
|
-
expect(
|
|
10
|
-
await ExtensionHostFormatting.format(
|
|
11
|
-
fakeExtensionHost,
|
|
12
|
-
'/test/file.txt',
|
|
13
|
-
''
|
|
14
|
-
)
|
|
15
|
-
).toEqual('')
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('executeFormattingProvider - error', async () => {
|
|
19
|
-
const fakeExtensionHost = {
|
|
20
|
-
invoke() {
|
|
21
|
-
throw new TypeError('x is not a function')
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
await expect(
|
|
25
|
-
ExtensionHostFormatting.format(fakeExtensionHost, '/test/file.txt', '')
|
|
26
|
-
).rejects.toThrowError(new TypeError('x is not a function'))
|
|
27
|
-
})
|