Skip to content

Commit

Permalink
added test for preValidation type
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kovalenko committed Jul 31, 2023
1 parent 8ab3717 commit 0c0e505
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import fastify, { RawReplyDefaultExpression, RawRequestDefaultExpression } from 'fastify';
import fastify, {
RawReplyDefaultExpression,
RawRequestDefaultExpression,
} from 'fastify';
import { expectError, expectType } from 'tsd';
import fastifyHttpProxy from '..';

const app = fastify();

app.register(fastifyHttpProxy, {
upstream: 'http://origin.asd'
upstream: 'http://origin.asd',
});

app.register(fastifyHttpProxy, {
Expand All @@ -24,46 +27,50 @@ app.register(fastifyHttpProxy, {
expectType<RawRequestDefaultExpression>(request.raw);
expectType<RawReplyDefaultExpression>(reply.raw);
},
preValidation: (request, reply) => {
expectType<RawRequestDefaultExpression>(request.raw);
expectType<RawReplyDefaultExpression>(reply.raw);
},
base: 'whatever',
cacheURLs: 10,
undici: {
connections: 128,
pipelining: 1,
keepAliveTimeout: 60 * 1000,
connect: {
rejectUnauthorized: false
}
rejectUnauthorized: false,
},
},
http: {
agentOptions: {
keepAliveMsecs: 10 * 60 * 1000
keepAliveMsecs: 10 * 60 * 1000,
},
requestOptions: {
timeout: 20000
}
timeout: 20000,
},
},
constraints: { version: '1.0.2' },
websocket: true,
wsUpstream: 'ws://origin.asd/connection'
wsUpstream: 'ws://origin.asd/connection',
});

expectError(
app.register(fastifyHttpProxy, {
thisOptionDoesNotExist: 'triggers a typescript error'
thisOptionDoesNotExist: 'triggers a typescript error',
})
);

expectError(
app.register(fastifyHttpProxy, {
upstream: 'http://origin.asd',
wsUpstream: 'ws://origin.asd'
wsUpstream: 'ws://origin.asd',
})
);

expectError(
app.register(fastifyHttpProxy, {
upstream: 'http://origin.asd',
websocket: false,
wsUpstream: 'asdf'
wsUpstream: 'asdf',
})
);

0 comments on commit 0c0e505

Please sign in to comment.