Skip to content

Commit 1a44d76

Browse files
committed
fix: tests
1 parent 60c7f8f commit 1a44d76

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

packages/http/fetch/src/middlewares/browser/middlewareFactory.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ export class MiddlewareFactory {
2727
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
2828
public static getDefaultMiddlewares(customFetch: (request: string, init: RequestInit) => Promise<Response> = (...args) => fetch(...args) as any): Middleware[] {
2929
// Browsers handles redirection automatically and do not require the redirectionHandler
30-
return [new RetryHandler(), new ParametersNameDecodingHandler(), new UserAgentHandler(), new CompressionHandler(), new HeadersInspectionHandler(), new CustomFetchHandler(customFetch), new UrlReplaceHandler()];
30+
return [new RetryHandler(), new ParametersNameDecodingHandler(), new UserAgentHandler(), new CompressionHandler(), new HeadersInspectionHandler(), new UrlReplaceHandler(), new CustomFetchHandler(customFetch)];
3131
}
3232
}

packages/http/fetch/test/browser/httpClient.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { assert, describe, it } from "vitest";
99

10-
import { CustomFetchHandler, HeadersInspectionHandler, HttpClient, Middleware, ParametersNameDecodingHandler, RedirectHandler, RetryHandler, UserAgentHandler } from "../../src";
10+
import { CustomFetchHandler, HeadersInspectionHandler, HttpClient, Middleware, ParametersNameDecodingHandler, RedirectHandler, RetryHandler, UrlReplaceHandler, UserAgentHandler } from "../../src";
1111
import { DummyFetchHandler } from "../common/middleware/dummyFetchHandler";
1212
import { CompressionHandler } from "../../src/middlewares/compressionHandler";
1313

@@ -42,7 +42,8 @@ describe("browser - HTTPClient.ts", () => {
4242
assert.isTrue(next?.next?.next instanceof UserAgentHandler);
4343
assert.isTrue(next?.next?.next?.next instanceof CompressionHandler);
4444
assert.isTrue(next?.next?.next?.next?.next instanceof HeadersInspectionHandler);
45-
assert.isTrue(next?.next?.next?.next?.next?.next instanceof CustomFetchHandler);
45+
assert.isTrue(next?.next?.next?.next?.next?.next instanceof UrlReplaceHandler);
46+
assert.isTrue(next?.next?.next?.next?.next?.next?.next instanceof CustomFetchHandler);
4647
});
4748

4849
it("Should set default middleware array with customFetchHandler if middleware parameter is undefined && customFetch is defined", () => {
@@ -58,7 +59,8 @@ describe("browser - HTTPClient.ts", () => {
5859
assert.isTrue(next?.next?.next instanceof UserAgentHandler);
5960
assert.isTrue(next?.next?.next?.next instanceof CompressionHandler);
6061
assert.isTrue(next?.next?.next?.next?.next instanceof HeadersInspectionHandler);
61-
assert.isTrue(next?.next?.next?.next?.next?.next instanceof CustomFetchHandler);
62+
assert.isTrue(next?.next?.next?.next?.next?.next instanceof UrlReplaceHandler);
63+
assert.isTrue(next?.next?.next?.next?.next?.next?.next instanceof CustomFetchHandler);
6264
});
6365

6466
it("Should set to default fetch handler middleware array if middleware parameter is null && customFetch is undefined", () => {

packages/http/fetch/test/browser/middlewareFactory.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
*/
77

88
import { assert, describe, it } from "vitest";
9-
import { CustomFetchHandler, HeadersInspectionHandler, MiddlewareFactory, ParametersNameDecodingHandler, RedirectHandler, RetryHandler, UserAgentHandler } from "../../src";
9+
import { CustomFetchHandler, HeadersInspectionHandler, MiddlewareFactory, ParametersNameDecodingHandler, RedirectHandler, RetryHandler, UrlReplaceHandler, UserAgentHandler } from "../../src";
1010
import { CompressionHandler } from "../../src/middlewares/compressionHandler";
1111

1212
describe("browser - MiddlewareFactory", () => {
1313
it("Should return the default pipeline", () => {
1414
const defaultMiddleWareArray = MiddlewareFactory.getDefaultMiddlewares();
15-
assert.equal(defaultMiddleWareArray.length, 7);
15+
assert.equal(defaultMiddleWareArray.length, 8);
1616
assert.isTrue(defaultMiddleWareArray[0] instanceof RetryHandler);
1717
assert.isTrue(defaultMiddleWareArray[1] instanceof RedirectHandler);
1818
assert.isTrue(defaultMiddleWareArray[2] instanceof ParametersNameDecodingHandler);
1919
assert.isTrue(defaultMiddleWareArray[3] instanceof UserAgentHandler);
2020
assert.isTrue(defaultMiddleWareArray[4] instanceof CompressionHandler);
2121
assert.isTrue(defaultMiddleWareArray[5] instanceof HeadersInspectionHandler);
22-
assert.isTrue(defaultMiddleWareArray[6] instanceof CustomFetchHandler);
22+
assert.isTrue(defaultMiddleWareArray[6] instanceof UrlReplaceHandler);
2323
assert.isTrue(defaultMiddleWareArray[7] instanceof CustomFetchHandler);
2424
});
2525
});

packages/http/fetch/test/node/MiddlewareFactory.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@
77

88
import { assert, describe, it } from "vitest";
99

10-
import { CustomFetchHandler, HeadersInspectionHandler, MiddlewareFactory, ParametersNameDecodingHandler, RedirectHandler, RetryHandler, UserAgentHandler } from "../../src";
10+
import { CustomFetchHandler, HeadersInspectionHandler, MiddlewareFactory, ParametersNameDecodingHandler, RedirectHandler, RetryHandler, UrlReplaceHandler, UserAgentHandler } from "../../src";
1111
import { CompressionHandler } from "../../src/middlewares/compressionHandler";
1212

1313
describe("node - MiddlewareFactory", () => {
1414
it("Should return the default pipeline", () => {
1515
const defaultMiddleWareArray = MiddlewareFactory.getDefaultMiddlewares();
16-
assert.equal(defaultMiddleWareArray.length, 7);
16+
assert.equal(defaultMiddleWareArray.length, 8);
1717

1818
assert.isTrue(defaultMiddleWareArray[0] instanceof RetryHandler);
1919
assert.isTrue(defaultMiddleWareArray[1] instanceof RedirectHandler);
2020
assert.isTrue(defaultMiddleWareArray[2] instanceof ParametersNameDecodingHandler);
2121
assert.isTrue(defaultMiddleWareArray[3] instanceof UserAgentHandler);
2222
assert.isTrue(defaultMiddleWareArray[4] instanceof CompressionHandler);
2323
assert.isTrue(defaultMiddleWareArray[5] instanceof HeadersInspectionHandler);
24-
assert.isTrue(defaultMiddleWareArray[6] instanceof CustomFetchHandler);
24+
assert.isTrue(defaultMiddleWareArray[6] instanceof UrlReplaceHandler);
25+
assert.isTrue(defaultMiddleWareArray[7] instanceof CustomFetchHandler);
2526
});
2627
});

packages/http/fetch/test/node/httpClient.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { assert, describe, it } from "vitest";
99

10-
import { CustomFetchHandler, HeadersInspectionHandler, HttpClient, ParametersNameDecodingHandler, RedirectHandler, RetryHandler, UserAgentHandler } from "../../src";
10+
import { CustomFetchHandler, HeadersInspectionHandler, HttpClient, ParametersNameDecodingHandler, RedirectHandler, RetryHandler, UrlReplaceHandler, UserAgentHandler } from "../../src";
1111
import { DummyFetchHandler } from "../common/middleware/dummyFetchHandler";
1212
import { CompressionHandler } from "../../src/middlewares/compressionHandler";
1313

@@ -42,7 +42,8 @@ describe("node - HTTPClient.ts", () => {
4242
assert.isTrue(next?.next?.next instanceof UserAgentHandler);
4343
assert.isTrue(next?.next?.next?.next instanceof CompressionHandler);
4444
assert.isTrue(next?.next?.next?.next?.next instanceof HeadersInspectionHandler);
45-
assert.isTrue(next?.next?.next?.next?.next?.next instanceof CustomFetchHandler);
45+
assert.isTrue(next?.next?.next?.next?.next?.next instanceof UrlReplaceHandler);
46+
assert.isTrue(next?.next?.next?.next?.next?.next?.next instanceof CustomFetchHandler);
4647
});
4748

4849
it("Should set default middleware array with customFetchHandler if middleware parameter is undefined && customFetch is defined", () => {
@@ -59,7 +60,8 @@ describe("node - HTTPClient.ts", () => {
5960
assert.isTrue(next?.next?.next instanceof UserAgentHandler);
6061
assert.isTrue(next?.next?.next?.next instanceof CompressionHandler);
6162
assert.isTrue(next?.next?.next?.next?.next instanceof HeadersInspectionHandler);
62-
assert.isTrue(next?.next?.next?.next?.next?.next instanceof CustomFetchHandler);
63+
assert.isTrue(next?.next?.next?.next?.next?.next instanceof UrlReplaceHandler);
64+
assert.isTrue(next?.next?.next?.next?.next?.next?.next instanceof CustomFetchHandler);
6365
});
6466

6567
it("Should set to default fetch handler middleware array if middleware parameter is null && customFetch is undefined", () => {

0 commit comments

Comments
 (0)