1- import { FastifyAdapter , NestFastifyApplication } from '@nestjs/platform-fastify' ;
1+ import {
2+ FastifyAdapter ,
3+ NestFastifyApplication ,
4+ } from '@nestjs/platform-fastify' ;
25import { Test } from '@nestjs/testing' ;
36import { expect } from 'chai' ;
47import { readFileSync } from 'fs' ;
@@ -20,40 +23,48 @@ describe('Fastify FileSend', () => {
2023 } ) ;
2124
2225 it ( 'should return a file from a stream' , async ( ) => {
23- return app . inject ( {
24- method : 'GET' ,
25- url : '/file/stream'
26- } ) . then ( ( { payload } ) => {
27- expect ( payload . toString ( ) ) . to . be . eq ( readmeString ) ;
28- } ) ;
26+ return app
27+ . inject ( {
28+ method : 'GET' ,
29+ url : '/file/stream' ,
30+ } )
31+ . then ( ( { payload } ) => {
32+ expect ( payload . toString ( ) ) . to . be . eq ( readmeString ) ;
33+ } ) ;
2934 } ) ;
3035 it ( 'should return a file from a buffer' , async ( ) => {
31- return app . inject ( {
32- method : 'GET' ,
33- url : '/file/buffer' ,
34- } ) . then ( ( { payload } ) => {
35- expect ( payload . toString ( ) ) . to . be . eq ( readmeString ) ;
36- } ) ;
36+ return app
37+ . inject ( {
38+ method : 'GET' ,
39+ url : '/file/buffer' ,
40+ } )
41+ . then ( ( { payload } ) => {
42+ expect ( payload . toString ( ) ) . to . be . eq ( readmeString ) ;
43+ } ) ;
3744 } ) ;
3845 /**
3946 * It seems that Fastify has a similar issue as Kamil initially pointed out
4047 * If a class has a `pipe` method, it will be treated as a stream. This means
4148 * that the `NonFile` test is a failed case for fastify, hence the skip.
4249 */
4350 it . skip ( 'should not stream a non-file' , async ( ) => {
44- return app . inject ( {
45- url : '/non-file/pipe-method' ,
46- method : 'get'
47- } ) . then ( ( { payload } ) => {
48- expect ( payload ) . to . be . eq ( { value : 'Hello world' } ) ;
49- } ) ;
51+ return app
52+ . inject ( {
53+ url : '/non-file/pipe-method' ,
54+ method : 'get' ,
55+ } )
56+ . then ( ( { payload } ) => {
57+ expect ( payload ) . to . be . eq ( { value : 'Hello world' } ) ;
58+ } ) ;
5059 } ) ;
5160 it ( 'should return a file from an RxJS stream' , async ( ) => {
52- return app . inject ( {
53- method : 'GET' ,
54- url : '/file/rxjs/stream'
55- } ) . then ( ( { payload } ) => {
56- expect ( payload . toString ( ) ) . to . be . eq ( readmeString ) ;
57- } ) ;
61+ return app
62+ . inject ( {
63+ method : 'GET' ,
64+ url : '/file/rxjs/stream' ,
65+ } )
66+ . then ( ( { payload } ) => {
67+ expect ( payload . toString ( ) ) . to . be . eq ( readmeString ) ;
68+ } ) ;
5869 } ) ;
5970} ) ;
0 commit comments