Skip to content

Commit

Permalink
Remove unnecessary space.enter() from some tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lawrence-forooghian committed Oct 19, 2023
1 parent c66bd09 commit ce44eb9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/Locations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe('Locations', () => {

it<SpaceTestContext>('sends a presence update on location set', async ({ space, presence }) => {
const spy = vi.spyOn(presence, 'update');
await space.enter();
await space.locations.set('location1');
expect(spy).toHaveBeenCalledWith(createLocationUpdate({ current: 'location1' }));
});
Expand Down
12 changes: 0 additions & 12 deletions src/Locks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ describe('Locks', () => {
space,
presence,
}) => {
await space.enter();

const presenceUpdate = vi.spyOn(presence, 'update');

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

it<SpaceTestContext>('includes attributes in the lock request when provided', async ({ space, presence }) => {
await space.enter();

const presenceUpdate = vi.spyOn(presence, 'update');

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

it<SpaceTestContext>('errors if a PENDING request already exists', async ({ space }) => {
await space.enter();

const lockID = 'test';
await space.locks.acquire(lockID);
expect(space.locks.acquire(lockID)).rejects.toThrowError();
Expand All @@ -108,7 +102,6 @@ describe('Locks', () => {
});

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

const emitSpy = vi.spyOn(space.locks, 'emit');
Expand Down Expand Up @@ -173,8 +166,6 @@ describe('Locks', () => {
},
])('$name', ({ desc, otherConnId, otherTimestamp, expectedSelfStatus, expectedOtherStatus }) => {
it<SpaceTestContext>(desc, async ({ client, space }) => {
await space.enter();

// process a PENDING request for the other member, which should
// transition to LOCKED
let msg = Realtime.PresenceMessage.fromValues({
Expand Down Expand Up @@ -230,7 +221,6 @@ describe('Locks', () => {
});

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

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

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

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

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

const lockID = 'test';
Expand Down

0 comments on commit ce44eb9

Please sign in to comment.