Skip to content

Commit

Permalink
More test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wkal-pubnub committed Nov 8, 2024
1 parent 65391dd commit 92c18a9
Show file tree
Hide file tree
Showing 11 changed files with 1,965 additions and 544 deletions.
4 changes: 4 additions & 0 deletions lib/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//process.env.PUBLISH_KEY = "pub-c-92e62c76-408a-4ac4-aefc-a1d20a83b2a6";
//process.env.SUBSCRIBE_KEY = "sub-c-d0b8e542-12a0-41c4-999f-a2d569dc4255";
//process.env.USER_ID = "test-user";

module.exports = {
bail: false,
reporters: ["default", "jest-junit"],
Expand Down
235 changes: 235 additions & 0 deletions lib/junit4.xml

Large diffs are not rendered by default.

193 changes: 193 additions & 0 deletions lib/junit6.xml

Large diffs are not rendered by default.

226 changes: 226 additions & 0 deletions lib/junit7.xml

Large diffs are not rendered by default.

200 changes: 200 additions & 0 deletions lib/junit_5.xml

Large diffs are not rendered by default.

563 changes: 563 additions & 0 deletions lib/junit_all.xml

Large diffs are not rendered by default.

44 changes: 21 additions & 23 deletions lib/tests/channel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ describe("Channel test", () => {
channelData: {},
}),
])
console.log(newChannels[0].channel.id)
expect(newChannels[0].channel.id.startsWith("direct.")).toBeTruthy()
expect(newChannels[1].channel.id).toBeDefined()
expect(newChannels[2].id).toBeDefined()
Expand Down Expand Up @@ -238,11 +237,10 @@ describe("Channel test", () => {
expect(inviteCallback).toHaveBeenCalledTimes(1)
expect(inviteCallback).toHaveBeenCalledWith(
expect.objectContaining({
payload: {
payload: expect.objectContaining({
channelType: "direct",
channelId: directConversation.channel.id,
type: expect.anything()
},
channelId: directConversation.channel.id
}),
})
)
await user.delete()
Expand Down Expand Up @@ -298,10 +296,10 @@ describe("Channel test", () => {
expect(inviteCallback).toHaveBeenCalledTimes(1)
expect(inviteCallback).toHaveBeenCalledWith(
expect.objectContaining({
payload: {
payload: expect.objectContaining({
channelType: "group",
channelId: result.channel.id,
},
}),
})
)

Expand Down Expand Up @@ -722,7 +720,7 @@ describe("Channel test", () => {

fail("Should have thrown an error")
} catch (error) {
expect(error).toEqual("You cannot quote messages from other channels")
expect(error.message).toEqual("You cannot quote messages from other channels")
} finally {
await otherChannel.delete()
}
Expand Down Expand Up @@ -760,6 +758,7 @@ describe("Channel test", () => {

const mockCallback = jest.fn()
const stopReceipts = await channel.streamReadReceipts(mockCallback)
await sleep(1000)
expect(mockCallback).toHaveBeenCalledTimes(1)
expect(mockCallback).toHaveBeenCalledWith({
[membership.lastReadMessageTimetoken]: ["test-user"],
Expand Down Expand Up @@ -807,15 +806,9 @@ describe("Channel test", () => {
const user = await createRandomUser()
const channel = await createRandomChannel()

console.log("Aaa")
const membership = await channel.invite(user)
console.log("bbb")
await sleep(200)
console.log("ccc")
console.log(membership)
console.log("ddd")
const membersData = await channel.getMembers()
console.log(membersData)

expect(membership).toBeDefined()
expect(membersData.members.find((member) => member.user.id === user.id)).toBeTruthy()
Expand Down Expand Up @@ -1062,7 +1055,7 @@ console.log("Aaa")
await chat.deleteUser(user1.id)
await chat.deleteUser(user2.id)
await chat.deleteUser(user3.id)
})
}, 15000)

test("should create a public chat channel", async () => {
const channelData = {
Expand All @@ -1073,6 +1066,11 @@ console.log("Aaa")
},
}

const channelToDelete = await chat.getChannel("public-channel-1")
if (channelToDelete) {
await channelToDelete.delete()
}

const publicChannel = await chat.createPublicConversation({
channelId: "public-channel-1",
channelData,
Expand Down Expand Up @@ -1100,10 +1098,10 @@ console.log("Aaa")
await sleep(150) // Wait for the message to be sent and cached
expect(moderationEventCallback).toHaveBeenCalledWith(
expect.objectContaining({
payload: {
payload: expect.objectContaining({
channelId: "PUBNUB_INTERNAL_MODERATION_some-channel",
restriction: "muted",
},
}),
})
)
moderationEventCallback.mockReset()
Expand All @@ -1112,10 +1110,10 @@ console.log("Aaa")
await sleep(150) // Wait for the message to be sent and cached
expect(moderationEventCallback).toHaveBeenCalledWith(
expect.objectContaining({
payload: {
payload: expect.objectContaining({
channelId: "PUBNUB_INTERNAL_MODERATION_some-channel",
restriction: "banned",
},
}),
})
)
moderationEventCallback.mockReset()
Expand All @@ -1124,10 +1122,10 @@ console.log("Aaa")
await sleep(150) // Wait for the message to be sent and cached
expect(moderationEventCallback).toHaveBeenCalledWith(
expect.objectContaining({
payload: {
payload: expect.objectContaining({
channelId: "PUBNUB_INTERNAL_MODERATION_some-channel",
restriction: "banned",
},
}),
})
)
moderationEventCallback.mockReset()
Expand All @@ -1136,10 +1134,10 @@ console.log("Aaa")
await sleep(150) // Wait for the message to be sent and cached
expect(moderationEventCallback).toHaveBeenCalledWith(
expect.objectContaining({
payload: {
payload: expect.objectContaining({
channelId: "PUBNUB_INTERNAL_MODERATION_some-channel",
restriction: "lifted",
},
}),
})
)

Expand Down
Loading

0 comments on commit 92c18a9

Please sign in to comment.