Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Freezystem committed Aug 27, 2024
1 parent 315779f commit 666a35d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions packages/moleculer-db-adapter-mongoose/test/unit/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,9 @@ if (process.versions.node.split(".")[0] < 14) {
},
});
adapter.init(broker, service);
const ctx = { service, params: { populate: ["firstVirtual", "secondVirtual", "thirdVirtual", "fourthVirtual"]}};
const res = adapter.getNativeVirtualPopulateQuery(ctx);
const params = { populate: ["firstVirtual", "secondVirtual", "thirdVirtual", "fourthVirtual"]};
const ctx = { service, params };
const res = adapter.getNativeVirtualPopulateQuery(ctx, params);

expect(res).toHaveLength(3);

Expand Down Expand Up @@ -878,8 +879,9 @@ if (process.versions.node.split(".")[0] < 14) {
},
});
adapter.init(broker, service);
const ctx = { service, params: { populate: ["firstVirtual", "secondVirtual", "thirdVirtual"]}};
const res = adapter.getNativeVirtualPopulateQuery(ctx);
const params = { populate: ["firstVirtual", "secondVirtual", "thirdVirtual"]};
const ctx = { service, params };
const res = adapter.getNativeVirtualPopulateQuery(ctx, params);

expect(res).toHaveLength(3);

Expand Down
8 changes: 4 additions & 4 deletions packages/moleculer-db/test/unit/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ describe("Test transformDocuments method", () => {
expect(res).toBe(doc);

expect(mockAdapter.entityToObject).toHaveBeenCalledTimes(1);
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(doc, ctx);
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(doc, ctx, ctx.params);

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

expect(mockAdapter.entityToObject).toHaveBeenCalledTimes(1);
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(doc, ctx);
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(doc, ctx, ctx.params);

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

expect(mockAdapter.entityToObject).toHaveBeenCalledTimes(2);
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(docs[0], ctx);
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(docs[1], ctx);
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(docs[0], ctx, ctx.params);
expect(mockAdapter.entityToObject).toHaveBeenCalledWith(docs[1], ctx, ctx.params);

expect(service.encodeID).toHaveBeenCalledTimes(2);
expect(service.encodeID).toHaveBeenCalledWith(docs[0]._id);
Expand Down

0 comments on commit 666a35d

Please sign in to comment.