Skip to content

Commit

Permalink
Adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arnautov-anton committed Nov 26, 2024
1 parent 81c0594 commit 72762d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions test/unit/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ describe('Channel _handleChannelEvent', function () {

await channel.query();

expect(Object.keys(channel.state.members).length).to.be.eq(2);
expect(Object.keys(channel.state.members).length).to.be.eq(1);
expect(Object.keys(channel.state.watchers).length).to.be.eq(1);
expect(Object.keys(channel.state.read).length).to.be.eq(1);
expect(channel.state.messages.length).to.be.eq(1);
Expand Down Expand Up @@ -1218,7 +1218,7 @@ describe('Channel lastMessage', async () => {

describe('Channel _initializeState', () => {
// FIXME: unwatching should remove members manually, not through state initialization
it.skip('should not keep members that have unwatched since last watch', async () => {
it('should not keep members that have unwatched since last watch', async () => {
const client = await getClientWithUser();
const channel = client.channel('messaging', uuidv4());

Expand Down
8 changes: 7 additions & 1 deletion test/unit/threads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ describe('Threads 2.0', () => {
beforeEach(() => {
client = new StreamChat('apiKey');
client._setUser({ id: TEST_USER_ID });
channelResponse = generateChannel({ channel: { id: uuidv4(), name: 'Test channel' } }).channel as ChannelResponse;
channelResponse = generateChannel({
channel: { id: uuidv4(), name: 'Test channel', members: [] },
}).channel as ChannelResponse;
channel = client.channel(channelResponse.type, channelResponse.id);
parentMessageResponse = generateMsg() as MessageResponse;
threadManager = new ThreadManager({ client });
Expand All @@ -57,12 +59,16 @@ describe('Threads 2.0', () => {
describe('Thread', () => {
it('initializes properly', () => {
const threadResponse = generateThreadResponse(channelResponse, parentMessageResponse);
// mimic pre-cached channel with existing members
channel._hydrateMembers({ members: [{ user: { id: TEST_USER_ID } }] });
const thread = new Thread({ client, threadData: threadResponse });
const state = thread.state.getLatestValue();

expect(threadResponse.channel.members).to.have.lengthOf(0);
expect(threadResponse.read).to.have.lengthOf(0);
expect(state.read).to.have.keys([TEST_USER_ID]);

expect(thread.channel.state.members).to.have.keys([TEST_USER_ID]);
expect(thread.id).to.equal(parentMessageResponse.id);
expect(thread.channel.data?.name).to.equal(channelResponse.name);
});
Expand Down

0 comments on commit 72762d4

Please sign in to comment.