|
1 | 1 | import fs from "fs"; |
2 | | -import stream from "stream"; |
| 2 | +import stream, { Stream } from "stream"; |
3 | 3 |
|
4 | 4 | import { getUserAgent } from "universal-user-agent"; |
5 | 5 | import fetchMock from "fetch-mock"; |
@@ -1021,4 +1021,35 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w== |
1021 | 1021 | expect(error.name).toEqual("AbortError"); |
1022 | 1022 | }); |
1023 | 1023 | }); |
| 1024 | + |
| 1025 | + it("request should pass the stream in the response", () => { |
| 1026 | + const mock = fetchMock.sandbox().get( |
| 1027 | + "https://api.github.com/repos/octokit-fixture-org/release-assets/tarball/main", |
| 1028 | + { |
| 1029 | + status: 200, |
| 1030 | + headers: { |
| 1031 | + "content-type": "application/x-gzip", |
| 1032 | + }, |
| 1033 | + body: fs.createReadStream(__filename), |
| 1034 | + }, |
| 1035 | + { |
| 1036 | + sendAsJson: false, |
| 1037 | + }, |
| 1038 | + ); |
| 1039 | + |
| 1040 | + return request("GET /repos/{owner}/{repo}/tarball/{branch}", { |
| 1041 | + owner: "octokit-fixture-org", |
| 1042 | + repo: "release-assets", |
| 1043 | + branch: "main", |
| 1044 | + request: { |
| 1045 | + parseSuccessResponseBody: false, |
| 1046 | + fetch: mock, |
| 1047 | + }, |
| 1048 | + }).then((response) => { |
| 1049 | + expect(response.status).toEqual(200); |
| 1050 | + expect(response.headers["content-type"]).toEqual("application/x-gzip"); |
| 1051 | + expect(response.data).toBeInstanceOf(Stream); |
| 1052 | + expect(mock.done()).toBe(true); |
| 1053 | + }); |
| 1054 | + }); |
1024 | 1055 | }); |
0 commit comments