Skip to content

Commit a3a36e3

Browse files
committed
ref(browser-utils): Revert getBodyString tests to original case
Signed-off-by: Kaung Zin Hein <83657429+Zen-cronic@users.noreply.github.com>
1 parent 514ef47 commit a3a36e3

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

packages/browser-utils/src/networkUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export function getBodyString(body: unknown, _logger: Logger = logger): [string
4545

4646
/**
4747
* Parses the fetch arguments to extract the request payload.
48+
*
4849
* We only support getting the body from the fetch options.
4950
*/
5051
export function getFetchRequestArgBody(fetchArgs: unknown[] = []): RequestInit['body'] | undefined {

packages/browser-utils/test/networkUtils.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@ import { describe, expect, it } from 'vitest';
66
import { getBodyString, getFetchRequestArgBody, serializeFormData } from '../src/networkUtils';
77

88
describe('getBodyString', () => {
9-
it('should work with a string', () => {
9+
it('works with a string', () => {
1010
const actual = getBodyString('abc');
1111
expect(actual).toEqual(['abc']);
1212
});
1313

14-
it('should work with URLSearchParams', () => {
14+
it('works with URLSearchParams', () => {
1515
const body = new URLSearchParams();
1616
body.append('name', 'Anne');
1717
body.append('age', '32');
1818
const actual = getBodyString(body);
1919
expect(actual).toEqual(['name=Anne&age=32']);
2020
});
2121

22-
it('should work with FormData', () => {
22+
it('works with FormData', () => {
2323
const body = new FormData();
24-
body.append('name', 'Bob');
24+
body.append('name', 'Anne');
2525
body.append('age', '32');
2626
const actual = getBodyString(body);
27-
expect(actual).toEqual(['name=Bob&age=32']);
27+
expect(actual).toEqual(['name=Anne&age=32']);
2828
});
2929

30-
it('should work with empty data', () => {
30+
it('works with empty data', () => {
3131
const body = undefined;
3232
const actual = getBodyString(body);
3333
expect(actual).toEqual([undefined]);
3434
});
3535

36-
it('should return unparsable with other types of data', () => {
36+
it('works with other type of data', () => {
3737
const body = {};
3838
const actual = getBodyString(body);
3939
expect(actual).toEqual([undefined, 'UNPARSEABLE_BODY_TYPE']);
@@ -42,15 +42,15 @@ describe('getBodyString', () => {
4242

4343
describe('getFetchRequestArgBody', () => {
4444
describe('valid types of body', () => {
45-
it('should work with json string', () => {
45+
it('works with json string', () => {
4646
const body = { data: [1, 2, 3] };
4747
const jsonBody = JSON.stringify(body);
4848

4949
const actual = getFetchRequestArgBody(['http://example.com', { method: 'POST', body: jsonBody }]);
5050
expect(actual).toEqual(jsonBody);
5151
});
5252

53-
it('should work with URLSearchParams', () => {
53+
it('works with URLSearchParams', () => {
5454
const body = new URLSearchParams();
5555
body.append('name', 'Anne');
5656
body.append('age', '32');
@@ -59,7 +59,7 @@ describe('getFetchRequestArgBody', () => {
5959
expect(actual).toEqual(body);
6060
});
6161

62-
it('should work with FormData', () => {
62+
it('works with FormData', () => {
6363
const body = new FormData();
6464
body.append('name', 'Bob');
6565
body.append('age', '32');
@@ -68,13 +68,13 @@ describe('getFetchRequestArgBody', () => {
6868
expect(actual).toEqual(body);
6969
});
7070

71-
it('should work with Blob', () => {
71+
it('works with Blob', () => {
7272
const body = new Blob(['example'], { type: 'text/plain' });
7373
const actual = getFetchRequestArgBody(['http://example.com', { method: 'POST', body }]);
7474
expect(actual).toEqual(body);
7575
});
7676

77-
it('should work with BufferSource (ArrayBufferView | ArrayBuffer)', () => {
77+
it('works with BufferSource (ArrayBufferView | ArrayBuffer)', () => {
7878
const body = new Uint8Array([1, 2, 3]);
7979
const actual = getFetchRequestArgBody(['http://example.com', { method: 'POST', body }]);
8080
expect(actual).toEqual(body);

packages/browser/src/integrations/graphqlClient.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface GraphQLClientOptions {
1515
endpoints: Array<string | RegExp>;
1616
}
1717

18-
// Standard graphql request shape: https://graphql.org/learn/serving-over-http/#post-request-and-body
18+
/** Standard graphql request shape: https://graphql.org/learn/serving-over-http/#post-request-and-body */
1919
interface GraphQLRequestPayload {
2020
query: string;
2121
operationName?: string;
@@ -118,7 +118,8 @@ function _getGraphQLOperation(requestBody: GraphQLRequestPayload): string {
118118
}
119119

120120
/**
121-
* Get the request body/payload based on the shape of the hint
121+
* Get the request body/payload based on the shape of the hint.
122+
*
122123
* Exported for tests only.
123124
*/
124125
export function getRequestPayloadXhrOrFetch(hint: XhrHint | FetchHint): string | undefined {
@@ -139,8 +140,8 @@ export function getRequestPayloadXhrOrFetch(hint: XhrHint | FetchHint): string |
139140

140141
/**
141142
* Extract the name and type of the operation from the GraphQL query.
143+
*
142144
* Exported for tests only.
143-
* @param query
144145
*/
145146
export function parseGraphQLQuery(query: string): GraphQLOperation {
146147
const queryRe = /^(?:\s*)(query|mutation|subscription)(?:\s*)(\w+)(?:\s*)[{(]/;

0 commit comments

Comments
 (0)