Skip to content

Commit 666a35d

Browse files
committed
fix tests
1 parent 315779f commit 666a35d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

packages/moleculer-db-adapter-mongoose/test/unit/index.spec.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,9 @@ if (process.versions.node.split(".")[0] < 14) {
815815
},
816816
});
817817
adapter.init(broker, service);
818-
const ctx = { service, params: { populate: ["firstVirtual", "secondVirtual", "thirdVirtual", "fourthVirtual"]}};
819-
const res = adapter.getNativeVirtualPopulateQuery(ctx);
818+
const params = { populate: ["firstVirtual", "secondVirtual", "thirdVirtual", "fourthVirtual"]};
819+
const ctx = { service, params };
820+
const res = adapter.getNativeVirtualPopulateQuery(ctx, params);
820821

821822
expect(res).toHaveLength(3);
822823

@@ -878,8 +879,9 @@ if (process.versions.node.split(".")[0] < 14) {
878879
},
879880
});
880881
adapter.init(broker, service);
881-
const ctx = { service, params: { populate: ["firstVirtual", "secondVirtual", "thirdVirtual"]}};
882-
const res = adapter.getNativeVirtualPopulateQuery(ctx);
882+
const params = { populate: ["firstVirtual", "secondVirtual", "thirdVirtual"]};
883+
const ctx = { service, params };
884+
const res = adapter.getNativeVirtualPopulateQuery(ctx, params);
883885

884886
expect(res).toHaveLength(3);
885887

packages/moleculer-db/test/unit/index.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ describe("Test transformDocuments method", () => {
542542
expect(res).toBe(doc);
543543

544544
expect(mockAdapter.entityToObject).toHaveBeenCalledTimes(1);
545-
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(doc, ctx);
545+
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(doc, ctx, ctx.params);
546546

547547
expect(service.encodeID).toHaveBeenCalledTimes(1);
548548
expect(service.encodeID).toHaveBeenCalledWith(doc._id);
@@ -566,7 +566,7 @@ describe("Test transformDocuments method", () => {
566566
expect(res).toBe(doc);
567567

568568
expect(mockAdapter.entityToObject).toHaveBeenCalledTimes(1);
569-
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(doc, ctx);
569+
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(doc, ctx, ctx.params);
570570

571571
expect(service.encodeID).toHaveBeenCalledTimes(1);
572572
expect(service.encodeID).toHaveBeenCalledWith(doc._id);
@@ -603,8 +603,8 @@ describe("Test transformDocuments method", () => {
603603
expect(res).toEqual(docs);
604604

605605
expect(mockAdapter.entityToObject).toHaveBeenCalledTimes(2);
606-
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(docs[0], ctx);
607-
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(docs[1], ctx);
606+
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(docs[0], ctx, ctx.params);
607+
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(docs[1], ctx, ctx.params);
608608

609609
expect(service.encodeID).toHaveBeenCalledTimes(2);
610610
expect(service.encodeID).toHaveBeenCalledWith(docs[0]._id);

0 commit comments

Comments
 (0)