Skip to content

Commit f0a7b21

Browse files
committed
test: lifecycle test
1 parent fd2c1a8 commit f0a7b21

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/tests/lifecycle.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
import { TestInfrastructure } from './tools'
3+
import { createLanguageClientManager, getLanguageClientOptions } from '..'
4+
5+
describe('Lifecycle', () => {
6+
test('Can dispose the language client manager immediately', async () => {
7+
const infrastructure = new TestInfrastructure(false, false, 2000)
8+
9+
const languageClient = createLanguageClientManager('java', infrastructure, {
10+
...getLanguageClientOptions('java'),
11+
createAdditionalFeatures: undefined
12+
})
13+
const startPromise = languageClient.start()
14+
await languageClient.dispose()
15+
await startPromise
16+
})
17+
})

src/tests/tools.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export class TestInfrastructure implements Infrastructure {
116116

117117
constructor (
118118
public automaticTextDocumentUpdate: boolean,
119-
public _useMutualizedProxy: boolean
119+
public _useMutualizedProxy: boolean,
120+
public connectionCreationDelay: number = 0
120121
) {}
121122

122123
useMutualizedProxy (languageClientId: LanguageClientId, options: LanguageClientOptions): boolean {
@@ -160,6 +161,7 @@ export class TestInfrastructure implements Infrastructure {
160161
exit: function (): void {}
161162
}
162163
const clientConnection = createConnection(() => c2, watchDog)
164+
await new Promise(resolve => setTimeout(resolve, this.connectionCreationDelay))
163165
this.connectionDeferred.resolve(clientConnection)
164166
c2.listen()
165167

0 commit comments

Comments
 (0)