Skip to content

Commit 7dae5fc

Browse files
Remove unnecessary space.enter() from some tests
These calls presumably exist because the method that they are testing requires that the client has entered the space. But calling `space.enter()` in the context of these tests does nothing useful — the underlying Realtime object is a mock, and the `presenceMap` objects in the tests’ contexts have already been configured such that a member is present for the space’s connection ID.
1 parent efc3989 commit 7dae5fc

File tree

2 files changed

+0
-13
lines changed

2 files changed

+0
-13
lines changed

src/Locations.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ describe('Locations', () => {
4949

5050
it<SpaceTestContext>('sends a presence update on location set', async ({ space, presence }) => {
5151
const spy = vi.spyOn(presence, 'update');
52-
await space.enter();
5352
await space.locations.set('location1');
5453
expect(spy).toHaveBeenCalledWith(createLocationUpdate({ current: 'location1' }));
5554
});

src/Locks.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ describe('Locks', () => {
4949
space,
5050
presence,
5151
}) => {
52-
await space.enter();
53-
5452
const presenceUpdate = vi.spyOn(presence, 'update');
5553

5654
const lockID = 'test';
@@ -71,8 +69,6 @@ describe('Locks', () => {
7169
});
7270

7371
it<SpaceTestContext>('includes attributes in the lock request when provided', async ({ space, presence }) => {
74-
await space.enter();
75-
7672
const presenceUpdate = vi.spyOn(presence, 'update');
7773

7874
const lockID = 'test';
@@ -89,8 +85,6 @@ describe('Locks', () => {
8985
});
9086

9187
it<SpaceTestContext>('errors if a PENDING request already exists', async ({ space }) => {
92-
await space.enter();
93-
9488
const lockID = 'test';
9589
await space.locks.acquire(lockID);
9690
expect(space.locks.acquire(lockID)).rejects.toThrowError();
@@ -108,7 +102,6 @@ describe('Locks', () => {
108102
});
109103

110104
it<SpaceTestContext>('sets a PENDING request to LOCKED', async ({ space }) => {
111-
await space.enter();
112105
const member = (await space.members.getSelf())!;
113106

114107
const emitSpy = vi.spyOn(space.locks, 'emit');
@@ -173,8 +166,6 @@ describe('Locks', () => {
173166
},
174167
])('$name', ({ desc, otherConnId, otherTimestamp, expectedSelfStatus, expectedOtherStatus }) => {
175168
it<SpaceTestContext>(desc, async ({ client, space }) => {
176-
await space.enter();
177-
178169
// process a PENDING request for the other member, which should
179170
// transition to LOCKED
180171
let msg = Realtime.PresenceMessage.fromValues({
@@ -230,7 +221,6 @@ describe('Locks', () => {
230221
});
231222

232223
it<SpaceTestContext>('sets a released request to UNLOCKED', async ({ space }) => {
233-
await space.enter();
234224
const member = (await space.members.getSelf())!;
235225

236226
let msg = Realtime.PresenceMessage.fromValues({
@@ -263,7 +253,6 @@ describe('Locks', () => {
263253
});
264254

265255
it<SpaceTestContext>('sets all locks to UNLOCKED when a member leaves', async ({ space }) => {
266-
await space.enter();
267256
const member = (await space.members.getSelf())!;
268257

269258
let msg = Realtime.PresenceMessage.fromValues({
@@ -311,7 +300,6 @@ describe('Locks', () => {
311300
});
312301

313302
it<SpaceTestContext>('removes the identified lock request from presence extras', async ({ space, presence }) => {
314-
await space.enter();
315303
const member = (await space.members.getSelf())!;
316304

317305
const lockID = 'test';

0 commit comments

Comments
 (0)