Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added collection test #16

Merged
merged 2 commits into from
Apr 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions test/project.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { getServer } from '../src/server';

import { UserCreateInput } from '../generated';
import { User } from '../src/modules/user/user.model';
import { UserService } from '../src/modules/user/user.service';

let binding: Binding;

Expand Down Expand Up @@ -78,8 +77,7 @@ describe('User', () => {
let response = await getUser(testData.user.username);
expect((response as User).id).toEqual(testData.user.username);

// This currently fails because the generated binding does not include field resolvers:
// expect((response as User).collection).toBeInstanceOf(Array);
expect((response as User).collection).toBeInstanceOf(Array);

// TODO: once we have a proper mutation for adding items,
// we will write a test that adds an item and then ensure that it exists here
Expand Down Expand Up @@ -128,7 +126,16 @@ async function signUpUser(data: UserCreateInput) {

async function getUser(userId: string): Promise<User | GraphQLError> {
try {
return binding.query.user({ where: { id: userId } });
return binding.query.user(
{ where: { id: userId } },
`
{
id
collection(query: "") {
id
}
}`
);
} catch (e) {
return getBindingError(e);
}
Expand Down