Skip to content

Commit 61c2b01

Browse files
Add tests for supporting Iterable collections across the lib (#2847)
1 parent d6ab262 commit 61c2b01

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/execution/__tests__/lists-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ describe('Execute: Accepts any iterable as list value', () => {
3737
});
3838

3939
it('Accepts function arguments as a List value', () => {
40-
function getArgs(...args: Array<string>) {
41-
return args;
40+
function getArgs(..._args: Array<string>) {
41+
return arguments;
4242
}
4343
const listField = getArgs('one', 'two');
4444

src/utilities/__tests__/astFromValue-test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,23 @@ describe('astFromValue', () => {
293293
{ kind: 'EnumValue', value: 'GOODBYE' },
294294
],
295295
});
296+
297+
function* listGenerator() {
298+
yield 1;
299+
yield 2;
300+
yield 3;
301+
}
302+
303+
expect(
304+
astFromValue(listGenerator(), new GraphQLList(GraphQLInt)),
305+
).to.deep.equal({
306+
kind: 'ListValue',
307+
values: [
308+
{ kind: 'IntValue', value: '1' },
309+
{ kind: 'IntValue', value: '2' },
310+
{ kind: 'IntValue', value: '3' },
311+
],
312+
});
296313
});
297314

298315
it('converts list singletons', () => {

src/utilities/__tests__/coerceInputValue-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,17 @@ describe('coerceInputValue', () => {
303303
expectValue(result).to.deep.equal([1, 2, 3]);
304304
});
305305

306+
it('returns no error for a valid iterable input', () => {
307+
function* listGenerator() {
308+
yield 1;
309+
yield 2;
310+
yield 3;
311+
}
312+
313+
const result = coerceValue(listGenerator(), TestList);
314+
expectValue(result).to.deep.equal([1, 2, 3]);
315+
});
316+
306317
it('returns an error for an invalid input', () => {
307318
const result = coerceValue([1, 'b', true, 4], TestList);
308319
expectErrors(result).to.deep.equal([

0 commit comments

Comments
 (0)