Skip to content

Commit

Permalink
fixing errors with test
Browse files Browse the repository at this point in the history
  • Loading branch information
prayanshchh committed Sep 8, 2024
1 parent c947850 commit 37de8c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/helpers/userAndOrg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const createTestUser = async (): Promise<TestUserType> => {
password: `pass${nanoid().toLowerCase()}`,
firstName: `firstName${nanoid().toLowerCase()}`,
lastName: `lastName${nanoid().toLowerCase()}`,
image: "exampleimageurl.com",
image: null,
});
const testUserAppProfile = await AppUserProfile.create({
userId: testUser._id,
Expand Down
12 changes: 8 additions & 4 deletions tests/resolvers/Post/likedBy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
TestUserType,
} from "../../helpers/userAndOrg";
import type { InterfacePost } from "../../../src/models";
import { Organization, Post } from "../../../src/models";
import { Organization, Post, User } from "../../../src/models";
import { posts as postResolver } from "../../../src/resolvers/Organization/posts";

let testPost: TestPostType;
Expand All @@ -20,6 +20,13 @@ let MONGOOSE_INSTANCE: typeof mongoose;
beforeAll(async () => {
MONGOOSE_INSTANCE = await connect();
[testUser, testOrganization, testPost] = await createTestPost();

await User.findByIdAndUpdate(testUser?._id, {
$set: {
image: "exampleimageurl.com",
},
});

await Post.updateOne(
{
_id: testPost?._id,
Expand Down Expand Up @@ -64,9 +71,6 @@ describe("resolvers -> organization -> posts", () => {
organization: testOrganization?._id,
}).lean();

console.log("postPayloadedge:", postPayload.edges[0].node.likedBy[0]);
console.log("posts:", posts[0].likedBy[0]);

expect(postPayload.edges.length).toEqual(posts.length);
expect(postPayload.totalCount).toEqual(posts.length);
const returnedPost = postPayload.edges[0].node;
Expand Down

0 comments on commit 37de8c9

Please sign in to comment.