Skip to content

Commit 7b43170

Browse files
committed
test: can fetch zero edges
1 parent be41dd9 commit 7b43170

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

src/builder/ConnectionBuilder.spec.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,54 @@ describe('ConnectionBuilder', () => {
285285
});
286286
});
287287

288+
test('Can fetch zero first edges', () => {
289+
const builder = new FooConnectionBuilder({
290+
first: 0,
291+
});
292+
293+
expect(builder.edgesPerPage).toBe(0);
294+
expect(builder.afterCursor).toBeUndefined();
295+
expect(builder.beforeCursor).toBeUndefined();
296+
297+
const connection = builder.build({
298+
totalEdges: 12,
299+
nodes: [],
300+
});
301+
302+
expect(connection).toMatchObject({
303+
pageInfo: {
304+
totalEdges: 12,
305+
hasNextPage: true,
306+
hasPreviousPage: false,
307+
},
308+
edges: [],
309+
});
310+
});
311+
312+
test('Can fetch zero last edges', () => {
313+
const builder = new FooConnectionBuilder({
314+
last: 0,
315+
});
316+
317+
expect(builder.edgesPerPage).toBe(0);
318+
expect(builder.afterCursor).toBeUndefined();
319+
expect(builder.beforeCursor).toBeUndefined();
320+
321+
const connection = builder.build({
322+
totalEdges: 12,
323+
nodes: [],
324+
});
325+
326+
expect(connection).toMatchObject({
327+
pageInfo: {
328+
totalEdges: 12,
329+
hasNextPage: true,
330+
hasPreviousPage: false,
331+
},
332+
edges: [],
333+
});
334+
});
335+
288336
describe('Connection arguments', () => {
289337
test('Should throw an error if the connection does not support offset pagination', () => {
290338
const createBuilder = () =>
@@ -337,7 +385,7 @@ describe('ConnectionBuilder', () => {
337385
const createBuilder = () =>
338386
new FooConnectionBuilder({
339387
after: '...',
340-
before: '...'
388+
before: '...',
341389
});
342390

343391
expect(createBuilder).toThrow(

0 commit comments

Comments
 (0)