Skip to content

Commit ab470f7

Browse files
committed
Add tsd tests for the new request.ws property
1 parent 92f70e6 commit ab470f7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

test/types/index.test-d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ app.get('/websockets-via-inferrence', { websocket: true }, async function (conne
2525
expectType<SocketStream>(connection);
2626
expectType<Server>(app.websocketServer);
2727
expectType<FastifyRequest<RequestGenericInterface>>(request)
28+
expectType<boolean>(request.ws);
2829
});
2930

3031
const handler: WebsocketHandler = async (connection, request) => {
@@ -38,6 +39,7 @@ app.get('/websockets-via-annotated-const', { websocket: true }, handler);
3839
app.get('/not-specifed', async (request, reply) => {
3940
expectType<FastifyRequest>(request);
4041
expectType<FastifyReply>(reply)
42+
expectType<boolean>(request.ws);
4143
});
4244

4345
app.get('/not-websockets', { websocket: false }, async (request, reply) => {
@@ -51,10 +53,12 @@ app.route({
5153
handler: (request, reply) => {
5254
expectType<FastifyRequest>(request);
5355
expectType<FastifyReply>(reply);
56+
expectType<boolean>(request.ws);
5457
},
5558
wsHandler: (connection, request) => {
5659
expectType<SocketStream>(connection);
5760
expectType<FastifyRequest<RouteGenericInterface>>(request);
61+
expectType<boolean>(request.ws);
5862
},
5963
});
6064

0 commit comments

Comments
 (0)