Apply strictNullChecks
to src/utils/*!exportUtils
(#10455
* Apply `strictNullChecks` to `src/utils/exportUtils` * strict fix * fix strictNullChecks issues in some utils * fix error message * test coverage * lint * more strictNullChecks * small optimisation for getUniqueRoomsWithIndividuals * tidy * test coverage
This commit is contained in:
parent
4ed6e39067
commit
81a4498a8f
18 changed files with 143 additions and 81 deletions
|
@ -31,15 +31,23 @@ describe("createMapSiteLinkFromEvent", () => {
|
|||
).toBeNull();
|
||||
});
|
||||
|
||||
it("returns OpenStreetMap link if event contains m.location", () => {
|
||||
it("returns OpenStreetMap link if event contains m.location with valid uri", () => {
|
||||
expect(createMapSiteLinkFromEvent(makeLocationEvent("geo:51.5076,-0.1276"))).toEqual(
|
||||
"https://www.openstreetmap.org/" + "?mlat=51.5076&mlon=-0.1276" + "#map=16/51.5076/-0.1276",
|
||||
);
|
||||
});
|
||||
|
||||
it("returns null if event contains m.location with invalid uri", () => {
|
||||
expect(createMapSiteLinkFromEvent(makeLocationEvent("123 Sesame St"))).toBeNull();
|
||||
});
|
||||
|
||||
it("returns OpenStreetMap link if event contains geo_uri", () => {
|
||||
expect(createMapSiteLinkFromEvent(makeLegacyLocationEvent("geo:51.5076,-0.1276"))).toEqual(
|
||||
"https://www.openstreetmap.org/" + "?mlat=51.5076&mlon=-0.1276" + "#map=16/51.5076/-0.1276",
|
||||
);
|
||||
});
|
||||
|
||||
it("returns null if event contains an invalid geo_uri", () => {
|
||||
expect(createMapSiteLinkFromEvent(makeLegacyLocationEvent("123 Sesame St"))).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -21,6 +21,14 @@ describe("parseGeoUri", () => {
|
|||
expect(parseGeoUri("")).toBeFalsy();
|
||||
});
|
||||
|
||||
it("returns undefined if latitude is not a number", () => {
|
||||
expect(parseGeoUri("geo:ABCD,16.3695,183")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("returns undefined if longitude is not a number", () => {
|
||||
expect(parseGeoUri("geo:48.2010,EFGH,183")).toBeUndefined();
|
||||
});
|
||||
|
||||
// We use some examples from the spec, but don't check semantics
|
||||
// like two textually-different URIs being equal, since we are
|
||||
// just a humble parser.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue