@trayio/commons
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -26,3 +26,3 @@ /// <reference types="node" /> | ||
headers: HttpHeaders; | ||
body: ArrayBuffer; | ||
body: Readable; | ||
}; | ||
@@ -29,0 +29,0 @@ export declare enum HttpMethod { |
@@ -211,4 +211,5 @@ "use strict"; | ||
}; | ||
const result = (0, function_1.pipe)(response, E.chain((httpResponse) => serialization.deserialize(httpResponse.body)), E.chain((encoded) => testResponseCodec.decode(encoded))); | ||
expect(result).toStrictEqual(E.right(testValue)); | ||
const result = (0, function_1.pipe)(response, TE.fromEither, TE.chain((httpResponse) => BufferExtensions_1.BufferExtensions.readableToArrayBuffer(httpResponse.body)), TE.match((error) => E.left(error), (buffer) => (0, function_1.pipe)(serialization.deserialize(buffer), E.chain((encoded) => testResponseCodec.decode(encoded))))); | ||
const resultE = yield result(); | ||
expect(resultE).toStrictEqual(E.right(testValue)); | ||
})); | ||
@@ -231,4 +232,5 @@ test('should send a POST request', () => __awaiter(this, void 0, void 0, function* () { | ||
}; | ||
const result = (0, function_1.pipe)(response, E.chain((httpResponse) => serialization.deserialize(httpResponse.body)), E.chain((encoded) => testResponseCodec.decode(encoded))); | ||
expect(result).toStrictEqual(E.right(testValue)); | ||
const result = (0, function_1.pipe)(response, TE.fromEither, TE.chain((httpResponse) => BufferExtensions_1.BufferExtensions.readableToArrayBuffer(httpResponse.body)), TE.match((error) => E.left(error), (buffer) => (0, function_1.pipe)(serialization.deserialize(buffer), E.chain((encoded) => testResponseCodec.decode(encoded))))); | ||
const resultE = yield result(); | ||
expect(resultE).toStrictEqual(E.right(testValue)); | ||
})); | ||
@@ -279,4 +281,5 @@ test('should send a POST request with multipart body', () => __awaiter(this, void 0, void 0, function* () { | ||
})(); | ||
const result = (0, function_1.pipe)(response, E.chain((httpResponse) => serialization.deserialize(httpResponse.body)), E.chain((res) => testMultiPartBodyTypeCodec.decode(res))); | ||
expect(result).toEqual(E.right(expect.objectContaining({ | ||
const result = (0, function_1.pipe)(response, TE.fromEither, TE.chain((httpResponse) => BufferExtensions_1.BufferExtensions.readableToArrayBuffer(httpResponse.body)), TE.match((error) => E.left(error), (buffer) => (0, function_1.pipe)(serialization.deserialize(buffer), E.chain((encoded) => testMultiPartBodyTypeCodec.decode(encoded))))); | ||
const resultE = yield result(); | ||
expect(resultE).toEqual(E.right(expect.objectContaining({ | ||
fields: testInput.fields, | ||
@@ -303,8 +306,8 @@ files: expect.objectContaining({ | ||
}; | ||
const expectedResponse = (0, function_1.pipe)(response, E.bindTo('httpResponse'), E.bind('serialisedErrorResponse', () => E.right(serialization.serialize(testErrorResponseCodec.encode(testErrorResponse)))), E.map(({ httpResponse, serialisedErrorResponse }) => ({ | ||
headers: httpResponse.headers, | ||
statusCode: 500, | ||
body: Buffer.from(serialisedErrorResponse), | ||
}))); | ||
expect(response).toStrictEqual(expectedResponse); | ||
if (E.isLeft(response)) { | ||
throw response.left; | ||
} | ||
const responseBodyE = yield BufferExtensions_1.BufferExtensions.readableToArrayBuffer(response.right.body)(); | ||
expect(response.right.statusCode).toStrictEqual(500); | ||
expect(responseBodyE).toStrictEqual(E.right(serialization.serialize(testErrorResponseCodec.encode(testErrorResponse)))); | ||
})); | ||
@@ -321,8 +324,8 @@ test('should parse a not found error response', () => __awaiter(this, void 0, void 0, function* () { | ||
}; | ||
const expectedResponse = (0, function_1.pipe)(response, E.bindTo('httpResponse'), E.bind('serialisedErrorResponse', () => E.right(serialization.serialize(testErrorResponseCodec.encode(testErrorResponse)))), E.map(({ httpResponse, serialisedErrorResponse }) => ({ | ||
headers: httpResponse.headers, | ||
statusCode: 404, | ||
body: Buffer.from(serialisedErrorResponse), | ||
}))); | ||
expect(response).toStrictEqual(expectedResponse); | ||
if (E.isLeft(response)) { | ||
throw response.left; | ||
} | ||
const responseBodyE = yield BufferExtensions_1.BufferExtensions.readableToArrayBuffer(response.right.body)(); | ||
expect(response.right.statusCode).toStrictEqual(404); | ||
expect(responseBodyE).toStrictEqual(E.right(serialization.serialize(testErrorResponseCodec.encode(testErrorResponse)))); | ||
})); | ||
@@ -329,0 +332,0 @@ }); |
{ | ||
"name": "@trayio/commons", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "Extensions to the standard/core libraries and basic features", | ||
@@ -5,0 +5,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104426
1895