You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-06 12:02:40 +03:00
Remove console coloring in favor of future PR
See https://github.com/matrix-org/matrix-js-sdk/pull/2915#discussion_r1041539703
This commit is contained in:
@@ -58,16 +58,6 @@ jest.mock("../../src/webrtc/call", () => ({
|
|||||||
supportsMatrixCall: jest.fn(() => false),
|
supportsMatrixCall: jest.fn(() => false),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
enum AnsiColorCode {
|
|
||||||
Red = 31,
|
|
||||||
Green = 32,
|
|
||||||
Yellow = 33,
|
|
||||||
}
|
|
||||||
// Add color to text in the terminal output
|
|
||||||
function decorateStringWithAnsiColor(inputString: string, decorationColor: AnsiColorCode): string {
|
|
||||||
return `\x1b[${decorationColor}m${inputString}\x1b[0m`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Utility function to ease the transition from our QueryDict type to a string record
|
// Utility function to ease the transition from our QueryDict type to a string record
|
||||||
// which we can use to stringify with URLSearchParams
|
// which we can use to stringify with URLSearchParams
|
||||||
function convertQueryDictToStringRecord(queryDict?: QueryDict): Record<string, string> {
|
function convertQueryDictToStringRecord(queryDict?: QueryDict): Record<string, string> {
|
||||||
@@ -209,21 +199,15 @@ describe("MatrixClient", function() {
|
|||||||
const receivedRequestQueryString = new URLSearchParams(
|
const receivedRequestQueryString = new URLSearchParams(
|
||||||
convertQueryDictToStringRecord(queryParams),
|
convertQueryDictToStringRecord(queryParams),
|
||||||
).toString();
|
).toString();
|
||||||
const receivedRequest = decorateStringWithAnsiColor(
|
const receivedRequestDebugString = `${method} ${prefix}${path}${receivedRequestQueryString}`;
|
||||||
`${method} ${prefix}${path}${receivedRequestQueryString}`,
|
|
||||||
AnsiColorCode.Red,
|
|
||||||
);
|
|
||||||
const expectedQueryString = new URLSearchParams(
|
const expectedQueryString = new URLSearchParams(
|
||||||
convertQueryDictToStringRecord(next.expectQueryParams),
|
convertQueryDictToStringRecord(next.expectQueryParams),
|
||||||
).toString();
|
).toString();
|
||||||
const expectedRequest = decorateStringWithAnsiColor(
|
const expectedRequestDebugString = `${next.method} ${next.prefix ?? ''}${next.path}${expectedQueryString}`;
|
||||||
`${next.method} ${next.prefix ?? ''}${next.path}${expectedQueryString}`,
|
|
||||||
AnsiColorCode.Green,
|
|
||||||
);
|
|
||||||
// If you're seeing this then you forgot to handle at least 1 pending request.
|
// If you're seeing this then you forgot to handle at least 1 pending request.
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`A pending request was not handled: ${receivedRequest} ` +
|
`A pending request was not handled: ${receivedRequestDebugString} ` +
|
||||||
`(next request expected was ${expectedRequest})\n` +
|
`(next request expected was ${expectedRequestDebugString})\n` +
|
||||||
`Check your tests to ensure your number of expectations lines up with your number of requests ` +
|
`Check your tests to ensure your number of expectations lines up with your number of requests ` +
|
||||||
`made, and that those requests match your expectations.`,
|
`made, and that those requests match your expectations.`,
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user