Merge branch 'develop' into travis/remove-skinning

This commit is contained in:
Travis Ralston
2022-03-31 19:25:43 -06:00
54 changed files with 1559 additions and 431 deletions

View File

@@ -16,7 +16,11 @@ limitations under the License.
import { Beacon } from "matrix-js-sdk/src/matrix";
import { msUntilExpiry, sortBeaconsByLatestExpiry } from "../../../src/utils/beacon";
import {
msUntilExpiry,
sortBeaconsByLatestExpiry,
sortBeaconsByLatestCreation,
} from "../../../src/utils/beacon";
import { makeBeaconInfoEvent } from "../../test-utils";
describe('beacon utils', () => {
@@ -80,4 +84,35 @@ describe('beacon utils', () => {
]);
});
});
describe('sortBeaconsByLatestCreation()', () => {
const roomId = '!room:server';
const aliceId = '@alive:server';
// 12h old, 12h left
const beacon1 = new Beacon(makeBeaconInfoEvent(aliceId,
roomId,
{ timeout: HOUR_MS * 24, timestamp: now - 12 * HOUR_MS },
'$1',
));
// 10h left
const beacon2 = new Beacon(makeBeaconInfoEvent(aliceId,
roomId,
{ timeout: HOUR_MS * 10, timestamp: now },
'$2',
));
// 1ms left
const beacon3 = new Beacon(makeBeaconInfoEvent(aliceId,
roomId,
{ timeout: HOUR_MS + 1, timestamp: now - HOUR_MS },
'$3',
));
it('sorts beacons by descending creation time', () => {
expect([beacon1, beacon2, beacon3].sort(sortBeaconsByLatestCreation)).toEqual([
beacon2, beacon3, beacon1,
]);
});
});
});