Skip to content

Commit

Permalink
Rename newConversation => newGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine committed Nov 19, 2024
1 parent 04fbb0d commit 931ce82
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 54 deletions.
5 changes: 1 addition & 4 deletions sdks/node-sdk/src/Conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ export class Conversations {
}
}

async newConversation(
accountAddresses: string[],
options?: CreateGroupOptions,
) {
async newGroup(accountAddresses: string[], options?: CreateGroupOptions) {
const group = await this.#conversations.createGroup(
accountAddresses,
options,
Expand Down
4 changes: 1 addition & 3 deletions sdks/node-sdk/test/Client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ describe("Client", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const group = await client1.conversations.newConversation([
user2.account.address,
]);
const group = await client1.conversations.newGroup([user2.account.address]);

await client2.conversations.sync();
const group2 = client2.conversations.getConversationById(group.id);
Expand Down
32 changes: 15 additions & 17 deletions sdks/node-sdk/test/Conversation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("Conversation", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);
const newName = "foo";
Expand All @@ -39,7 +39,7 @@ describe("Conversation", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);
const imageUrl = "https://foo/bar.jpg";
Expand All @@ -65,7 +65,7 @@ describe("Conversation", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);
const newDescription = "foo";
Expand All @@ -91,7 +91,7 @@ describe("Conversation", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);
const pinnedFrameUrl = "https://foo/bar";
Expand Down Expand Up @@ -119,7 +119,7 @@ describe("Conversation", () => {
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const client3 = await createRegisteredClient(user3);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);

Expand Down Expand Up @@ -158,7 +158,7 @@ describe("Conversation", () => {
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const client3 = await createRegisteredClient(user3);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);

Expand Down Expand Up @@ -194,7 +194,7 @@ describe("Conversation", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);

Expand Down Expand Up @@ -226,7 +226,7 @@ describe("Conversation", () => {
codecs: [new TestCodec()],
});
await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);

Expand All @@ -242,7 +242,7 @@ describe("Conversation", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);

Expand Down Expand Up @@ -281,7 +281,7 @@ describe("Conversation", () => {
codecs: [new TestCodec()],
});
await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);

Expand All @@ -297,7 +297,7 @@ describe("Conversation", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);

Expand All @@ -311,7 +311,7 @@ describe("Conversation", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);

Expand Down Expand Up @@ -350,7 +350,7 @@ describe("Conversation", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);

Expand All @@ -376,7 +376,7 @@ describe("Conversation", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);

Expand Down Expand Up @@ -404,9 +404,7 @@ describe("Conversation", () => {
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const client3 = await createRegisteredClient(user3);
const group = await client1.conversations.newConversation([
user2.account.address,
]);
const group = await client1.conversations.newGroup([user2.account.address]);
expect(group).toBeDefined();
const dmGroup = await client1.conversations.newDm(user3.account.address);
expect(dmGroup).toBeDefined();
Expand Down
58 changes: 28 additions & 30 deletions sdks/node-sdk/test/Conversations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ describe("Conversations", () => {
expect((await client.conversations.listGroups()).length).toBe(0);
});

it("should create a new conversation", async () => {
it("should create a group", async () => {
const user1 = createUser();
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const conversation = await client1.conversations.newConversation([
const conversation = await client1.conversations.newGroup([
user2.account.address,
]);
expect(conversation).toBeDefined();
Expand Down Expand Up @@ -71,7 +71,7 @@ describe("Conversations", () => {
expect((await client2.conversations.listGroups()).length).toBe(1);
});

it("should create a dm group", async () => {
it("should create a dm", async () => {
const user1 = createUser();
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
Expand Down Expand Up @@ -142,9 +142,7 @@ describe("Conversations", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
await createRegisteredClient(user2);
const group = await client1.conversations.newConversation([
user2.account.address,
]);
const group = await client1.conversations.newGroup([user2.account.address]);
expect(group).toBeDefined();
expect(group.id).toBeDefined();
const foundGroup = client1.conversations.getConversationById(group.id);
Expand All @@ -157,9 +155,7 @@ describe("Conversations", () => {
const user2 = createUser();
const client1 = await createRegisteredClient(user1);
await createRegisteredClient(user2);
const group = await client1.conversations.newConversation([
user2.account.address,
]);
const group = await client1.conversations.newGroup([user2.account.address]);
const messageId = await group.send("gm!");
expect(messageId).toBeDefined();

Expand All @@ -168,7 +164,7 @@ describe("Conversations", () => {
expect(message!.id).toBe(messageId);
});

it("should create a new conversation with options", async () => {
it("should create a group with options", async () => {
const user1 = createUser();
const user2 = createUser();
const user3 = createUser();
Expand All @@ -179,7 +175,7 @@ describe("Conversations", () => {
await createRegisteredClient(user3);
await createRegisteredClient(user4);
await createRegisteredClient(user5);
const groupWithName = await client1.conversations.newConversation(
const groupWithName = await client1.conversations.newGroup(
[user2.account.address],
{
groupName: "foo",
Expand All @@ -189,7 +185,7 @@ describe("Conversations", () => {
expect(groupWithName.name).toBe("foo");
expect(groupWithName.imageUrl).toBe("");

const groupWithImageUrl = await client1.conversations.newConversation(
const groupWithImageUrl = await client1.conversations.newGroup(
[user3.account.address],
{
groupImageUrlSquare: "https://foo/bar.png",
Expand All @@ -199,16 +195,18 @@ describe("Conversations", () => {
expect(groupWithImageUrl.name).toBe("");
expect(groupWithImageUrl.imageUrl).toBe("https://foo/bar.png");

const groupWithNameAndImageUrl =
await client1.conversations.newConversation([user4.account.address], {
const groupWithNameAndImageUrl = await client1.conversations.newGroup(
[user4.account.address],
{
groupImageUrlSquare: "https://foo/bar.png",
groupName: "foo",
});
},
);
expect(groupWithNameAndImageUrl).toBeDefined();
expect(groupWithNameAndImageUrl.name).toBe("foo");
expect(groupWithNameAndImageUrl.imageUrl).toBe("https://foo/bar.png");

const groupWithPermissions = await client1.conversations.newConversation(
const groupWithPermissions = await client1.conversations.newGroup(
[user4.account.address],
{
permissions: GroupPermissionsOptions.AdminOnly,
Expand All @@ -232,7 +230,7 @@ describe("Conversations", () => {
updateGroupPinnedFrameUrlPolicy: 2,
});

const groupWithDescription = await client1.conversations.newConversation(
const groupWithDescription = await client1.conversations.newGroup(
[user2.account.address],
{
groupDescription: "foo",
Expand All @@ -243,7 +241,7 @@ describe("Conversations", () => {
expect(groupWithDescription.imageUrl).toBe("");
expect(groupWithDescription.description).toBe("foo");

const groupWithPinnedFrameUrl = await client1.conversations.newConversation(
const groupWithPinnedFrameUrl = await client1.conversations.newGroup(
[user2.account.address],
{
groupPinnedFrameUrl: "https://foo/bar",
Expand All @@ -264,10 +262,10 @@ describe("Conversations", () => {
const client2 = await createRegisteredClient(user2);
const client3 = await createRegisteredClient(user3);
const stream = client3.conversations.stream();
const conversation1 = await client1.conversations.newConversation([
const conversation1 = await client1.conversations.newGroup([
user3.account.address,
]);
const conversation2 = await client2.conversations.newConversation([
const conversation2 = await client2.conversations.newGroup([
user3.account.address,
]);
let count = 0;
Expand Down Expand Up @@ -301,10 +299,10 @@ describe("Conversations", () => {
const client4 = await createRegisteredClient(user4);
const stream = client3.conversations.streamGroups();
await client4.conversations.newDm(user3.account.address);
const group1 = await client1.conversations.newConversation([
const group1 = await client1.conversations.newGroup([
user3.account.address,
]);
const group2 = await client2.conversations.newConversation([
const group2 = await client2.conversations.newGroup([
user3.account.address,
]);
let count = 0;
Expand All @@ -331,8 +329,8 @@ describe("Conversations", () => {
const client3 = await createRegisteredClient(user3);
const client4 = await createRegisteredClient(user4);
const stream = client3.conversations.streamDms();
await client1.conversations.newConversation([user3.account.address]);
await client2.conversations.newConversation([user3.account.address]);
await client1.conversations.newGroup([user3.account.address]);
await client2.conversations.newGroup([user3.account.address]);
const group3 = await client4.conversations.newDm(user3.account.address);
let count = 0;
for await (const convo of stream) {
Expand All @@ -353,8 +351,8 @@ describe("Conversations", () => {
const client1 = await createRegisteredClient(user1);
const client2 = await createRegisteredClient(user2);
const client3 = await createRegisteredClient(user3);
await client1.conversations.newConversation([user2.account.address]);
await client1.conversations.newConversation([user3.account.address]);
await client1.conversations.newGroup([user2.account.address]);
await client1.conversations.newGroup([user3.account.address]);

const stream = await client1.conversations.streamAllMessages();

Expand Down Expand Up @@ -391,8 +389,8 @@ describe("Conversations", () => {
const client2 = await createRegisteredClient(user2);
const client3 = await createRegisteredClient(user3);
const client4 = await createRegisteredClient(user4);
await client1.conversations.newConversation([user2.account.address]);
await client1.conversations.newConversation([user3.account.address]);
await client1.conversations.newGroup([user2.account.address]);
await client1.conversations.newGroup([user3.account.address]);
await client1.conversations.newDm(user4.account.address);

const stream = await client1.conversations.streamAllGroupMessages();
Expand Down Expand Up @@ -437,8 +435,8 @@ describe("Conversations", () => {
const client2 = await createRegisteredClient(user2);
const client3 = await createRegisteredClient(user3);
const client4 = await createRegisteredClient(user4);
await client1.conversations.newConversation([user2.account.address]);
await client1.conversations.newConversation([user3.account.address]);
await client1.conversations.newGroup([user2.account.address]);
await client1.conversations.newGroup([user3.account.address]);
await client1.conversations.newDm(user4.account.address);

const stream = await client1.conversations.streamAllDmMessages();
Expand Down

0 comments on commit 931ce82

Please sign in to comment.