You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-30 04:23:07 +03:00
Fix: Handle parsing of a beacon info event without asset (#2591)
* test case * handle missing beacon info asset * default beacon info asset type to self * make BeaconLocationState.assetType optional
This commit is contained in:
@ -15,6 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
import { MatrixEvent } from "../../../src";
|
||||
import { M_BEACON_INFO } from "../../../src/@types/beacon";
|
||||
import {
|
||||
isTimestampInDuration,
|
||||
Beacon,
|
||||
@ -129,6 +130,24 @@ describe('Beacon', () => {
|
||||
expect(beacon.beaconInfo).toBeTruthy();
|
||||
});
|
||||
|
||||
it('creates beacon without error from a malformed event', () => {
|
||||
const event = new MatrixEvent({
|
||||
type: M_BEACON_INFO.name,
|
||||
room_id: roomId,
|
||||
state_key: userId,
|
||||
content: {},
|
||||
});
|
||||
const beacon = new Beacon(event);
|
||||
|
||||
expect(beacon.beaconInfoId).toEqual(event.getId());
|
||||
expect(beacon.roomId).toEqual(roomId);
|
||||
expect(beacon.isLive).toEqual(false);
|
||||
expect(beacon.beaconInfoOwner).toEqual(userId);
|
||||
expect(beacon.beaconInfoEventType).toEqual(liveBeaconEvent.getType());
|
||||
expect(beacon.identifier).toEqual(`${roomId}_${userId}`);
|
||||
expect(beacon.beaconInfo).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('isLive()', () => {
|
||||
it('returns false when beacon is explicitly set to not live', () => {
|
||||
const beacon = new Beacon(notLiveBeaconEvent);
|
||||
|
Reference in New Issue
Block a user