Skip to content

Commit dc915d3

Browse files
committed
Fix failing tests and lint errors
1 parent 6563b77 commit dc915d3

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

test/unit/service.spec.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async function startService(mixinOptions, baseSchema) {
3535
describe("Test Service", () => {
3636
describe("Test created handler", () => {
3737
it("should register a route with default options", async () => {
38-
const { broker, svc, stop } = await startService();
38+
const { svc, stop } = await startService();
3939

4040
expect(svc.shouldUpdateGraphqlSchema).toBe(true);
4141

@@ -59,15 +59,15 @@ describe("Test Service", () => {
5959

6060
describe("Test `/` route handler", () => {
6161
it("should prepare graphql schema & call handler", async () => {
62-
const { broker, svc, stop } = await startService();
62+
const { svc, stop } = await startService();
6363

6464
// Test `/` alias
6565
svc.prepareGraphQLSchema = jest.fn();
6666
svc.graphqlHandler = jest.fn(() => "result");
6767
const fakeReq = { req: 1 };
6868
const fakeRes = { res: 1 };
6969

70-
const res = svc.settings.routes[0].aliases["/"].call(svc, fakeReq, fakeRes);
70+
const res = await svc.settings.routes[0].aliases["/"].call(svc, fakeReq, fakeRes);
7171

7272
expect(res).toBe("result");
7373
expect(svc.prepareGraphQLSchema).toBeCalledTimes(1);
@@ -78,7 +78,7 @@ describe("Test Service", () => {
7878
});
7979

8080
it("should call sendError if error occured", async () => {
81-
const { broker, svc, stop } = await startService();
81+
const { svc, stop } = await startService();
8282

8383
const err = new Error("Something happened");
8484
svc.sendError = jest.fn();
@@ -89,7 +89,7 @@ describe("Test Service", () => {
8989
const fakeReq = { req: 1 };
9090
const fakeRes = { res: 1 };
9191

92-
const res = svc.settings.routes[0].aliases["/"].call(svc, fakeReq, fakeRes);
92+
const res = await svc.settings.routes[0].aliases["/"].call(svc, fakeReq, fakeRes);
9393

9494
expect(res).toBeUndefined();
9595
expect(svc.prepareGraphQLSchema).toBeCalledTimes(1);
@@ -103,15 +103,15 @@ describe("Test Service", () => {
103103

104104
describe("Test `GET /.well-known/apollo/server-health` route handler", () => {
105105
it("should prepare graphql schema & call handler", async () => {
106-
const { broker, svc, stop } = await startService();
106+
const { svc, stop } = await startService();
107107

108108
// Test `/` alias
109109
svc.prepareGraphQLSchema = jest.fn();
110110
svc.graphqlHandler = jest.fn(() => "result");
111111
const fakeReq = { req: 1 };
112112
const fakeRes = { res: 1 };
113113

114-
const res = svc.settings.routes[0].aliases[
114+
const res = await svc.settings.routes[0].aliases[
115115
"GET /.well-known/apollo/server-health"
116116
].call(svc, fakeReq, fakeRes);
117117

@@ -124,7 +124,7 @@ describe("Test Service", () => {
124124
});
125125

126126
it("should call sendError if error occured", async () => {
127-
const { broker, svc, stop } = await startService();
127+
const { svc, stop } = await startService();
128128

129129
const err = new Error("Something happened");
130130
svc.sendResponse = jest.fn();
@@ -135,7 +135,7 @@ describe("Test Service", () => {
135135
const fakeReq = { req: 1 };
136136
const fakeRes = { res: 1 };
137137

138-
const res = svc.settings.routes[0].aliases[
138+
const res = await svc.settings.routes[0].aliases[
139139
"GET /.well-known/apollo/server-health"
140140
].call(svc, fakeReq, fakeRes);
141141

@@ -160,7 +160,7 @@ describe("Test Service", () => {
160160
});
161161

162162
it("should register a route with custom options", async () => {
163-
const { broker, svc, stop } = await startService({
163+
const { svc, stop } = await startService({
164164
routeOptions: {
165165
path: "/apollo-server",
166166

@@ -314,7 +314,7 @@ describe("Test Service", () => {
314314
describe("Test methods", () => {
315315
describe("Test 'invalidateGraphQLSchema'", () => {
316316
it("should create the 'graphql' action", async () => {
317-
const { broker, svc, stop } = await startService();
317+
const { svc, stop } = await startService();
318318

319319
svc.shouldUpdateGraphqlSchema = false;
320320

@@ -395,7 +395,7 @@ describe("Test Service", () => {
395395
it("should call actionResolvers", async () => {
396396
const { svc, stop } = await startService();
397397

398-
svc.createActionResolver = jest.fn((name, r) => jest.fn());
398+
svc.createActionResolver = jest.fn(() => jest.fn());
399399

400400
const resolvers = {
401401
author: {
@@ -1030,7 +1030,7 @@ describe("Test Service", () => {
10301030
describe("Test 'generateGraphQLSchema'", () => {
10311031
it("should create an empty schema", async () => {
10321032
makeExecutableSchema.mockImplementation(() => "generated-schema");
1033-
const { broker, svc, stop } = await startService();
1033+
const { svc, stop } = await startService();
10341034

10351035
const res = svc.generateGraphQLSchema([]);
10361036
expect(res).toBe("generated-schema");
@@ -1048,7 +1048,7 @@ describe("Test Service", () => {
10481048
it("should create a schema with schemaDirectives", async () => {
10491049
makeExecutableSchema.mockClear();
10501050
const UniqueIdDirective = jest.fn();
1051-
const { broker, svc, stop } = await startService({
1051+
const { svc, stop } = await startService({
10521052
schemaDirectives: {
10531053
uid: UniqueIdDirective,
10541054
},
@@ -1081,7 +1081,7 @@ describe("Test Service", () => {
10811081
},
10821082
},
10831083
};
1084-
const { broker, svc, stop } = await startService({
1084+
const { svc, stop } = await startService({
10851085
typeDefs: `
10861086
scalar Date
10871087
`,
@@ -1310,7 +1310,7 @@ describe("Test Service", () => {
13101310
makeExecutableSchema.mockImplementation(() => {
13111311
throw new Error("Something is wrong");
13121312
});
1313-
const { broker, svc, stop } = await startService();
1313+
const { svc, stop } = await startService();
13141314

13151315
expect(() => svc.generateGraphQLSchema([])).toThrow(Errors.MoleculerServerError);
13161316

0 commit comments

Comments
 (0)