Skip to content

Commit 0306d12

Browse files
committed
resolve any
1 parent dc4bc4d commit 0306d12

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

template/test/integration/api.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ServiceBroker } from "moleculer";
1616
import APISchema from "../../services/api.service.js";
1717
import GreeterSchema from "../../services/greeter.service.js";
1818
{{#dbService}}
19-
import ProductsSchema from "../../services/products.service.js";
19+
import ProductsSchema, { ProductEntity } from "../../services/products.service.js";
2020
{{/dbService}}
2121

2222
describe("Test HTTP API gateway", () => {
@@ -34,7 +34,7 @@ describe("Test HTTP API gateway", () => {
3434
await broker.start();
3535

3636
// Add small delay for API service to register product's custom endpoints
37-
await (broker.Promise as any).delay(500);
37+
await new Promise(resolve => setTimeout(resolve, 500));
3838
});
3939
afterAll(() => broker.stop());
4040

@@ -234,9 +234,9 @@ describe("Test Socket.IO API gateway", () => {
234234
* @param {Object} params
235235
* @returns
236236
*/
237-
function callAwait(client: Socket, action: string, params?: any) {
237+
function callAwait<TResult = unknown>(client: Socket, action: string, params?: any): Promise<TResult> {
238238
return new Promise(function (resolve, reject) {
239-
client.emit("call", action, params, function (err: any, res: any) {
239+
client.emit("call", action, params, function (err: any, res: TResult) {
240240
if (err) return reject(err);
241241
resolve(res);
242242
});
@@ -292,11 +292,11 @@ describe("Test Socket.IO API gateway", () => {
292292
});
293293

294294
it("test 'products.create'", async () => {
295-
const res = await callAwait(client, "products.create", {
295+
const res = await callAwait<ProductEntity>(client, "products.create", {
296296
name: "Super Phone",
297297
price: 123
298298
});
299-
PHONE_ID = (res as any).id;
299+
PHONE_ID = res.id;
300300

301301
expect(res).toEqual({
302302
id: expect.any(String),
@@ -526,9 +526,9 @@ describe("Test GraphQL API gateway", () => {
526526
}
527527
}
528528
`;
529-
const res = await request(`http://localhost:${port}/graphql`, query);
529+
const res = await request<{ createProduct: ProductEntity }>(`http://localhost:${port}/graphql`, query);
530530

531-
PHONE_ID = (res as any).createProduct.id;
531+
PHONE_ID = res.createProduct.id;
532532

533533
expect(res).toEqual({
534534
createProduct: {

template/test/unit/services/inventory.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ describe("Test 'inventory' service", () => {
1414
}
1515
})
1616
]
17-
}) as any;
17+
});
1818

1919
// Mock adapter methods
20-
broker.channelAdapter.init = vi.fn();
21-
broker.channelAdapter.connect = vi.fn();
22-
broker.channelAdapter.disconnect = vi.fn();
23-
broker.channelAdapter.subscribe = vi.fn();
24-
broker.channelAdapter.unsubscribe = vi.fn();
25-
broker.channelAdapter.publish = vi.fn();
20+
(broker as any).channelAdapter.init = vi.fn();
21+
(broker as any).channelAdapter.connect = vi.fn();
22+
(broker as any).channelAdapter.disconnect = vi.fn();
23+
(broker as any).channelAdapter.subscribe = vi.fn();
24+
(broker as any).channelAdapter.unsubscribe = vi.fn();
25+
(broker as any).channelAdapter.publish = vi.fn();
2626

2727
broker.emit = vi.fn();
2828

template/test/unit/services/products.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ describe("Test 'products' service", () => {
159159
const createActionFn = vi.fn();
160160
broker.createService({
161161
name: "products",
162-
mixins: [TestService as any],
162+
mixins: [TestService],
163163
actions: {
164164
create: {
165165
handler: createActionFn

0 commit comments

Comments
 (0)