@@ -11,6 +11,8 @@ import {
1111
1212import { request } from "../src" ;
1313import { isPlainObject } from "is-plain-object" ;
14+ import fs from "fs" ;
15+ import stream from "stream" ;
1416
1517const userAgent = `octokit-request.js/0.0.0-development ${ getUserAgent ( ) } ` ;
1618
@@ -914,4 +916,36 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
914916 expect ( error . status ) . toEqual ( 500 ) ;
915917 } ) ;
916918 } ) ;
919+
920+ it ( "validate request with readstream data" , ( ) => {
921+ const size = fs . statSync ( __filename ) . size ;
922+ const mock = fetchMock
923+ . sandbox ( )
924+ . post (
925+ "https://api.github.com/repos/octokit-fixture-org/release-assets/releases/v1.0.0/assets" ,
926+ {
927+ status : 200 ,
928+ }
929+ ) ;
930+
931+ return request ( "POST /repos/{owner}/{repo}/releases/{release_id}/assets" , {
932+ owner : "octokit-fixture-org" ,
933+ repo : "release-assets" ,
934+ release_id : "v1.0.0" ,
935+ request : {
936+ fetch : mock ,
937+ } ,
938+ headers : {
939+ "content-type" : "text/json" ,
940+ "content-length" : size ,
941+ } ,
942+ data : fs . createReadStream ( __filename ) ,
943+ name : "test-upload.txt" ,
944+ label : "test" ,
945+ } ) . then ( ( response ) => {
946+ expect ( response . status ) . toEqual ( 200 ) ;
947+ expect ( mock . lastOptions ( ) ?. body ) . toBeInstanceOf ( stream . Readable ) ;
948+ expect ( mock . done ( ) ) . toBe ( true ) ;
949+ } ) ;
950+ } ) ;
917951} ) ;
0 commit comments