Skip to content

Commit

Permalink
fixed lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
KrutikaBhatt committed Mar 4, 2023
1 parent 7433229 commit 064571c
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions tests/resolvers/Subscription/messageSentToGroupChat.spec.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
import "dotenv/config";
import { describe, it, expect, beforeAll, afterAll } from "vitest";
import { connect, disconnect } from "../../helpers/db";
import mongoose from "mongoose";
import {
testGroupChatType,
createTestGroupChatMessage,
} from "../../helpers/groupChat";
import { filterFunction } from "../../../src/resolvers/Subscription/messageSentToGroupChat";

let MONGOOSE_INSTANCE: typeof mongoose | null;
let testGroupChat: testGroupChatType;

beforeAll(async () => {
MONGOOSE_INSTANCE = await connect();
testGroupChat = (await createTestGroupChatMessage())[2];
});
afterAll(async () => {
await disconnect(MONGOOSE_INSTANCE!);
});

describe("src -> resolvers -> Subscription -> messageSentToGroupChat", () => {
it("subscription filter function returns true", async () => {
const { messageSentToGroupChat: messageSentToGroupChatPayload } =
await import(
"../../../src/resolvers/Subscription/messageSentToGroupChat"
);

const _args = {};
const _parent = {};
const context = {
pubsub: {
asyncIterator: (_action: "MESSAGE_SENT_TO_GROUP_CHAT") => {
return;
},
},
context: { currentUserId: testGroupChat!.users[0] },
};
const payload = {
messageSentToGroupChat: {
groupChatMessageBelongsTo: testGroupChat!._id,
},
};
// @ts-ignore
messageSentToGroupChatPayload._parent = _parent;
// @ts-ignore
messageSentToGroupChatPayload._args = _args;
// @ts-ignore
messageSentToGroupChatPayload.context = context;
// @ts-ignore
messageSentToGroupChatPayload.payload = payload;
// @ts-ignore
const x = messageSentToGroupChatPayload?.subscribe(_parent, _args, context);
expect(x).not.toBe(null);
expect(await filterFunction(payload, context)).toBe(true);
});
});
import "dotenv/config";
import { describe, it, expect, beforeAll, afterAll } from "vitest";
import { connect, disconnect } from "../../helpers/db";
import mongoose from "mongoose";
import {
testGroupChatType,
createTestGroupChatMessage,
} from "../../helpers/groupChat";
import { filterFunction } from "../../../src/resolvers/Subscription/messageSentToGroupChat";

let MONGOOSE_INSTANCE: typeof mongoose | null;
let testGroupChat: testGroupChatType;

beforeAll(async () => {
MONGOOSE_INSTANCE = await connect();
testGroupChat = (await createTestGroupChatMessage())[2];
});
afterAll(async () => {
await disconnect(MONGOOSE_INSTANCE!);
});

describe("src -> resolvers -> Subscription -> messageSentToGroupChat", () => {
it("subscription filter function returns true", async () => {
const { messageSentToGroupChat: messageSentToGroupChatPayload } =
await import(
"../../../src/resolvers/Subscription/messageSentToGroupChat"
);

const _args = {};
const _parent = {};
const context = {
pubsub: {
asyncIterator: (_action: "MESSAGE_SENT_TO_GROUP_CHAT") => {
return;
},
},
context: { currentUserId: testGroupChat!.users[0] },
};
const payload = {
messageSentToGroupChat: {
groupChatMessageBelongsTo: testGroupChat!._id,
},
};
// @ts-ignore
messageSentToGroupChatPayload._parent = _parent;
// @ts-ignore
messageSentToGroupChatPayload._args = _args;
// @ts-ignore
messageSentToGroupChatPayload.context = context;
// @ts-ignore
messageSentToGroupChatPayload.payload = payload;
// @ts-ignore
const x = messageSentToGroupChatPayload?.subscribe(_parent, _args, context);
expect(x).not.toBe(null);
expect(await filterFunction(payload, context)).toBe(true);
});
});

0 comments on commit 064571c

Please sign in to comment.