Skip to content

Commit

Permalink
test(datalayer): remove updated schemas tests
Browse files Browse the repository at this point in the history
Reactive-GraphQL is currently throwing an error, completing the observable
In the future (d2iq-archive/reactive-graphql#13) we
would want to aggregate these non-structural errors in the output instead,
this is why I choose to deferr this test a little.
  • Loading branch information
Daniel Schmidt committed Mar 14, 2019
1 parent 5572552 commit 109e43c
Showing 1 changed file with 8 additions and 52 deletions.
60 changes: 8 additions & 52 deletions packages/@extension-kid/data-layer/__tests__/dataLayer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,11 @@ describe("DataLayer", () => {
}
`;

await expect(toPromise(dl.query(query).pipe(take(1)))).resolves.toEqual({
data: {},
errors: [
{
message:
"There was a GraphQL error: Error: reactive-graphql: field 'task' was not found on type 'Job'. The only fields found in this Object are: id,docker."
}
]
});
await expect(toPromise(dl.query(query).pipe(take(1)))).rejects.toEqual(
new Error(
"reactive-graphql: field 'task' was not found on type 'Job'. The only fields found in this Object are: id,docker."
)
);

await container.bindAsync(DataLayerExtensionType, bts => {
bts.to(TasksExtension).inSingletonScope();
Expand All @@ -338,47 +334,7 @@ describe("DataLayer", () => {
});
});

it("extends a schema while a query is running", async () => {
jest.useRealTimers();
await container.bindAsync(DataLayerExtensionType, bts => {
bts.to(JobsExtension).inSingletonScope();
});
const dl: DataLayer = container.get<DataLayer>(DataLayerType);

const query = gql`
query {
jobs {
task {
id
}
}
}
`;

const obs = dl.query(query).pipe(take(2));
const mockNext = jest.fn();
const subscriptionDone = new Promise(resolve =>
obs.subscribe({ next: mockNext, complete: resolve })
);
await Promise.all([
subscriptionDone,
container.bindAsync(DataLayerExtensionType, bts => {
bts.to(TasksExtension).inSingletonScope();
})
]);

expect(mockNext).toHaveBeenCalledTimes(2);
expect(mockNext).toHaveBeenCalledWith({
data: {},
errors: [
{
message:
"There was a GraphQL error: Error: reactive-graphql: field 'task' was not found on type 'Job'. The only fields found in this Object are: id,docker."
}
]
});
expect(mockNext).toHaveBeenCalledWith({
data: { jobs: [{ task: { id: "footask" } }] }
});
});
// This can currently not be done, because reactive-graphql completes the observable as an error
// It relates to this issue: https://github.com/mesosphere/reactive-graphql/issues/13
it("extends a schema while a query is running");
});

0 comments on commit 109e43c

Please sign in to comment.