Apply strictNullChecks
to src/utils/beacon/*
(#10337)
* strictnullchecks fixes in utils/beacon * user filterBoolean
This commit is contained in:
parent
503df62191
commit
72404d7216
5 changed files with 38 additions and 10 deletions
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { M_TIMESTAMP } from "matrix-js-sdk/src/@types/location";
|
||||
import { Beacon } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { msUntilExpiry, sortBeaconsByLatestExpiry, sortBeaconsByLatestCreation } from "../../../src/utils/beacon";
|
||||
|
@ -68,9 +69,25 @@ describe("beacon utils", () => {
|
|||
makeBeaconInfoEvent(aliceId, roomId, { timeout: HOUR_MS + 1, timestamp: now - HOUR_MS }, "$3"),
|
||||
);
|
||||
|
||||
const noTimestampEvent = makeBeaconInfoEvent(
|
||||
aliceId,
|
||||
roomId,
|
||||
{ timeout: HOUR_MS + 1, timestamp: undefined },
|
||||
"$3",
|
||||
);
|
||||
// beacon info helper defaults to date when timestamp is falsy
|
||||
// hard set it to undefined
|
||||
// @ts-ignore
|
||||
noTimestampEvent.event.content[M_TIMESTAMP.name] = undefined;
|
||||
const beaconNoTimestamp = new Beacon(noTimestampEvent);
|
||||
|
||||
it("sorts beacons by descending expiry time", () => {
|
||||
expect([beacon2, beacon3, beacon1].sort(sortBeaconsByLatestExpiry)).toEqual([beacon1, beacon2, beacon3]);
|
||||
});
|
||||
|
||||
it("sorts beacons with timestamps before beacons without", () => {
|
||||
expect([beaconNoTimestamp, beacon3].sort(sortBeaconsByLatestExpiry)).toEqual([beacon3, beaconNoTimestamp]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("sortBeaconsByLatestCreation()", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue