Skip to content

Commit 0467c85

Browse files
committed
test: excludeGraphQLFetch should default to not assuming GraphQL when missing the URL
1 parent 036b746 commit 0467c85

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/excludeGraphQLFetch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export const excludeGraphQLFetch: BeforeBreadcrumbCallback = (breadcrumb) => {
1414
return breadcrumb;
1515
};
1616

17-
export const withoutGraphQLFetch = (
18-
beforeBreadcrumb: BeforeBreadcrumbCallback
19-
): BeforeBreadcrumbCallback => {
17+
export function withoutGraphQLFetch(
18+
beforeBreadcrumb: BeforeBreadcrumbCallback,
19+
): BeforeBreadcrumbCallback {
2020
return (breadcrumb, hint) => {
2121
const withoutFetch = excludeGraphQLFetch(breadcrumb, hint);
2222
if (withoutFetch === null) {
@@ -25,4 +25,4 @@ export const withoutGraphQLFetch = (
2525

2626
return beforeBreadcrumb(withoutFetch, hint);
2727
};
28-
};
28+
}

tests/excludeGraphQLFetch.test.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,30 @@ describe('excludeGraphQLFetch', () => {
66
excludeGraphQLFetch({
77
category: 'fetch',
88
data: { url: 'https://example.com/graphql' },
9-
})
9+
}),
1010
).toBeNull();
1111
});
1212

13+
it('should default to not assuming GraphQL when missing the URL', () => {
14+
const breadcrumb = {
15+
category: 'fetch',
16+
data: {},
17+
};
18+
19+
expect(excludeGraphQLFetch(breadcrumb)).toBe(breadcrumb);
20+
});
21+
1322
it('should leave non-GraphQL fetches', () => {
1423
const breadcrumb = {
1524
category: 'fetch',
1625
data: { url: 'https://example.com' },
1726
};
18-
expect(excludeGraphQLFetch(breadcrumb)).toEqual(breadcrumb);
27+
expect(excludeGraphQLFetch(breadcrumb)).toBe(breadcrumb);
1928
});
2029

2130
it('should leave non-fetch breadcrumbs', () => {
2231
const breadcrumb = { category: 'not-fetch' };
23-
expect(excludeGraphQLFetch(breadcrumb)).toEqual(breadcrumb);
32+
expect(excludeGraphQLFetch(breadcrumb)).toBe(breadcrumb);
2433
});
2534
});
2635

@@ -34,7 +43,7 @@ describe('withoutGraphQLFetch', () => {
3443
wrapped({
3544
category: 'fetch',
3645
data: { url: 'https://example.com/graphql' },
37-
})
46+
}),
3847
).toBeNull();
3948
expect(callback).not.toHaveBeenCalled();
4049
});
@@ -49,7 +58,7 @@ describe('withoutGraphQLFetch', () => {
4958

5059
const wrapped = withoutGraphQLFetch(callback);
5160

52-
expect(wrapped(initial, hint)).toEqual(altered);
61+
expect(wrapped(initial, hint)).toBe(altered);
5362
expect(callback).toHaveBeenCalledTimes(1);
5463
expect(callback).toHaveBeenCalledWith(initial, hint);
5564
});

0 commit comments

Comments
 (0)