You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
Live location sharing - Aggregate beacon locations on beacons (#2268)
* add timestamp sorting util Signed-off-by: Kerry Archibald <kerrya@element.io> * basic wiring Signed-off-by: Kerry Archibald <kerrya@element.io> * quick handle for redacted beacons Signed-off-by: Kerry Archibald <kerrya@element.io> * remove fdescribe Signed-off-by: Kerry Archibald <kerrya@element.io> * test adding locations Signed-off-by: Kerry Archibald <kerrya@element.io> * tidy comments Signed-off-by: Kerry Archibald <kerrya@element.io> * test client Signed-off-by: Kerry Archibald <kerrya@element.io> * fix monitorLiveness for update Signed-off-by: Kerry Archibald <kerrya@element.io> * lint Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
@ -33,6 +33,7 @@ import * as testUtils from "../test-utils/test-utils";
|
||||
import { makeBeaconInfoContent } from "../../src/content-helpers";
|
||||
import { M_BEACON_INFO } from "../../src/@types/beacon";
|
||||
import { Room } from "../../src";
|
||||
import { makeBeaconEvent } from "../test-utils/beacon";
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
||||
@ -1025,5 +1026,34 @@ describe("MatrixClient", function() {
|
||||
);
|
||||
expect(requestContent).toEqual(content);
|
||||
});
|
||||
|
||||
describe('processBeaconEvents()', () => {
|
||||
it('does nothing when events is falsy', () => {
|
||||
const room = new Room(roomId, client, userId);
|
||||
const roomStateProcessSpy = jest.spyOn(room.currentState, 'processBeaconEvents');
|
||||
|
||||
client.processBeaconEvents(room, undefined);
|
||||
expect(roomStateProcessSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does nothing when events is of length 0', () => {
|
||||
const room = new Room(roomId, client, userId);
|
||||
const roomStateProcessSpy = jest.spyOn(room.currentState, 'processBeaconEvents');
|
||||
|
||||
client.processBeaconEvents(room, []);
|
||||
expect(roomStateProcessSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('calls room states processBeaconEvents with m.beacon events', () => {
|
||||
const room = new Room(roomId, client, userId);
|
||||
const roomStateProcessSpy = jest.spyOn(room.currentState, 'processBeaconEvents');
|
||||
|
||||
const messageEvent = testUtils.mkMessage({ room: roomId, user: userId, event: true });
|
||||
const beaconEvent = makeBeaconEvent(userId);
|
||||
|
||||
client.processBeaconEvents(room, [messageEvent, beaconEvent]);
|
||||
expect(roomStateProcessSpy).toHaveBeenCalledWith([beaconEvent]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user