Skip to content

Commit

Permalink
✅ Add test for createREquestUrl util
Browse files Browse the repository at this point in the history
  • Loading branch information
cermakjiri committed Sep 9, 2021
1 parent 47321f4 commit 657f972
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import logger from 'loglevel';
import { createRequestUrl } from '..';

describe('createRequestUrl', () => {
it('composes request url', () => {
const url = createRequestUrl(
'/user/:id',
{
baseURL: 'https://example.com',
uriParams: {
id: '2',
},
params: new URLSearchParams({
page: '1',
}),
headers: {},
},
{
logger,
},
);

expect(url).toBe('https://example.com/user/2?page=1');
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { GeneralConfig } from '../../../core/general-config';

import type { RequestConfig } from '../../../../types';
import type { FinalRequestConfig } from '../mergeRequestConfigs';

import { setUriParams } from './uriParams';

Expand All @@ -13,7 +13,7 @@ export function joinUrlChunks(baseUrl?: string, ...path: string[]) {

export function createRequestUrl(
requestUrl: string,
requestConfig: RequestConfig,
requestConfig: FinalRequestConfig,
generalConfig: GeneralConfig,
): string {
try {
Expand Down
3 changes: 2 additions & 1 deletion packages/@ackee/antonio-core/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { FinalRequestConfig } from 'modules/request/utils';
import type { IterableStream } from './modules/response/iterableStream';

export type Primitive = bigint | boolean | null | number | string | undefined;
Expand Down Expand Up @@ -180,6 +181,6 @@ export interface RequestResult<D = any> {

export interface RequestParams {
url: string;
config: RequestConfig;
config: FinalRequestConfig;
bodyData: RequestBodyData;
}

0 comments on commit 657f972

Please sign in to comment.