Skip to content

Commit 84ecc2b

Browse files
committed
cleanup
1 parent 85042a6 commit 84ecc2b

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

packages/sveltekit/test/client/load.test.ts

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ describe('wrapLoadWithSentry', () => {
259259
};
260260
};
261261

262-
it.only('creates a fetch span and attaches tracing headers if event.fetch was called', async () => {
262+
it('creates a fetch span and attaches tracing headers if event.fetch was called', async () => {
263263
const wrappedLoad = wrapLoadWithSentry(load);
264264
await wrappedLoad(MOCK_LOAD_ARGS);
265265

@@ -279,30 +279,19 @@ describe('wrapLoadWithSentry', () => {
279279
);
280280
expect(mockTrace).toHaveBeenNthCalledWith(2, spanCtx, expect.any(Function));
281281

282-
// TODO: refactor
283-
const expectedFetchArgs =
284-
originalFetchArgs.length > 1
285-
? [
286-
originalFetchArgs[0],
287-
{
288-
...(originalFetchArgs[1] as RequestInit),
289-
headers: {
290-
// @ts-ignore that's fine
291-
...(originalFetchArgs[1].headers as RequestInit['headers']),
292-
baggage: expect.any(String),
293-
'sentry-trace': expect.any(String),
294-
},
295-
},
296-
]
297-
: [
298-
originalFetchArgs[0],
299-
{
300-
headers: {
301-
baggage: expect.any(String),
302-
'sentry-trace': expect.any(String),
303-
},
304-
},
305-
];
282+
const hasSecondArg = originalFetchArgs.length > 1;
283+
const expectedFetchArgs = [
284+
originalFetchArgs[0],
285+
{
286+
...(hasSecondArg && (originalFetchArgs[1] as RequestInit)),
287+
headers: {
288+
// @ts-ignore that's fine
289+
...(hasSecondArg && (originalFetchArgs[1].headers as RequestInit['headers'])),
290+
baggage: expect.any(String),
291+
'sentry-trace': expect.any(String),
292+
},
293+
},
294+
];
306295

307296
expect(mockedSveltekitFetch).toHaveBeenCalledWith(...expectedFetchArgs);
308297
});

0 commit comments

Comments
 (0)