@@ -7,7 +7,7 @@ import {assertRequest} from "./test-utils";
77import { InterceptorInterface } from "../../src/InterceptorInterface" ;
88import { Interceptor } from "../../src/decorator/Interceptor" ;
99import { UseInterceptor } from "../../src/decorator/UseInterceptor" ;
10- import { Controller } from "../../src/decorator/Controller " ;
10+ import { JsonController } from "../../src/decorator/JsonController " ;
1111import { Get } from "../../src/decorator/Get" ;
1212import { Action } from "../../src/Action" ;
1313import { ContentType } from "../../src/decorator/ContentType" ;
@@ -23,19 +23,27 @@ describe("special result value treatment", () => {
2323 // reset metadata args storage
2424 getMetadataArgsStorage ( ) . reset ( ) ;
2525
26- @Controller ( )
26+ @JsonController ( )
2727 class HandledController {
2828
2929 @Get ( "/stream" )
3030 @ContentType ( "text/plain" )
3131 getStream ( ) {
3232 return createReadStream ( path . resolve ( __dirname , "../../../../test/resources/sample-text-file.txt" ) ) ;
3333 }
34-
34+
3535 @Get ( "/buffer" )
36+ @ContentType ( "application/octet-stream" )
3637 getBuffer ( ) {
3738 return new Buffer ( rawData ) ;
3839 }
40+
41+ @Get ( "/array" )
42+ @ContentType ( "application/octet-stream" )
43+ getUIntArray ( ) {
44+ return new Uint8Array ( rawData ) ;
45+ }
46+
3947 }
4048
4149 } ) ;
@@ -56,11 +64,20 @@ describe("special result value treatment", () => {
5664 } ) ;
5765 } ) ;
5866
59- describe ( "should send raw binary data" , ( ) => {
67+ describe ( "should send raw binary data from Buffer " , ( ) => {
6068 assertRequest ( [ 3001 , 3002 ] , "get" , "buffer" , response => {
6169 expect ( response ) . to . be . status ( 200 ) ;
6270 expect ( response ) . to . have . header ( "content-type" , "application/octet-stream" ) ;
6371 expect ( response . body ) . to . be . equal ( new Buffer ( rawData ) . toString ( ) ) ;
6472 } ) ;
6573 } ) ;
74+
75+ describe ( "should send raw binary data from UIntArray" , ( ) => {
76+ assertRequest ( [ 3001 , 3002 ] , "get" , "array" , response => {
77+ expect ( response ) . to . be . status ( 200 ) ;
78+ expect ( response ) . to . have . header ( "content-type" , "application/octet-stream" ) ;
79+ expect ( response . body ) . to . be . equal ( Buffer . from ( rawData ) . toString ( ) ) ;
80+ } ) ;
81+ } ) ;
82+
6683} ) ;
0 commit comments