Skip to content

Commit 23a5b16

Browse files
authored
Add test cases to make send* fail when client is stopped (#989)
1 parent 543d8d8 commit 23a5b16

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

client-node-tests/src/integration.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,18 @@ suite('Server activation', () => {
17141714
await client.stop();
17151715
});
17161716

1717+
test('Start server fails on request when stopped once', async () => {
1718+
const client = createClient();
1719+
assert.strictEqual(client.state, lsclient.State.Stopped);
1720+
const result: number = await client.sendRequest('request', { value: 10 });
1721+
assert.strictEqual(client.state, lsclient.State.Running);
1722+
assert.strictEqual(result, 11);
1723+
await client.stop();
1724+
await assert.rejects(async () => {
1725+
await client.sendRequest('request', { value: 10 });
1726+
}, /Client is not running/);
1727+
});
1728+
17171729
test('Start server on notification', async () => {
17181730
const client = createClient();
17191731
assert.strictEqual(client.state, lsclient.State.Stopped);
@@ -1722,6 +1734,17 @@ suite('Server activation', () => {
17221734
await client.stop();
17231735
});
17241736

1737+
test('Start server fails on notification when stopped once', async () => {
1738+
const client = createClient();
1739+
assert.strictEqual(client.state, lsclient.State.Stopped);
1740+
await client.sendNotification('notification');
1741+
assert.strictEqual(client.state, lsclient.State.Running);
1742+
await client.stop();
1743+
await assert.rejects(async () => {
1744+
await client.sendNotification('notification');
1745+
}, /Client is not running/);
1746+
});
1747+
17251748
test('Add pending request handler', async () => {
17261749
const client = createClient();
17271750
assert.strictEqual(client.state, lsclient.State.Stopped);

0 commit comments

Comments
 (0)