Apply prettier formatting

This commit is contained in:
Michael Weimann 2022-12-12 12:24:14 +01:00
parent 1cac306093
commit 526645c791
No known key found for this signature in database
GPG key ID: 53F535A266BB9584
1576 changed files with 65385 additions and 62478 deletions

View file

@ -28,7 +28,7 @@ import { isSelfLocation } from "../../../src/utils/location";
describe("isSelfLocation", () => {
it("Returns true for a full m.asset event", () => {
const content = makeLocationContent("", '0', Date.now());
const content = makeLocationContent("", "0", Date.now());
expect(isSelfLocation(content)).toBe(true);
});
@ -62,11 +62,12 @@ describe("isSelfLocation", () => {
it("Returns false for an unknown asset type", () => {
const content = makeLocationContent(
undefined, /* text */
undefined /* text */,
"geo:foo",
0,
undefined, /* description */
"org.example.unknown" as unknown as LocationAssetType);
undefined /* description */,
"org.example.unknown" as unknown as LocationAssetType,
);
expect(isSelfLocation(content)).toBe(false);
});
});

View file

@ -17,12 +17,12 @@ limitations under the License.
import { locationEventGeoUri } from "../../../src/utils/location";
import { makeLegacyLocationEvent, makeLocationEvent } from "../../test-utils/location";
describe('locationEventGeoUri()', () => {
it('returns m.location uri when available', () => {
describe("locationEventGeoUri()", () => {
it("returns m.location uri when available", () => {
expect(locationEventGeoUri(makeLocationEvent("geo:51.5076,-0.1276"))).toEqual("geo:51.5076,-0.1276");
});
it('returns legacy uri when m.location content not found', () => {
it("returns legacy uri when m.location content not found", () => {
expect(locationEventGeoUri(makeLegacyLocationEvent("geo:51.5076,-0.1276"))).toEqual("geo:51.5076,-0.1276");
});
});

View file

@ -20,28 +20,26 @@ import { makeLegacyLocationEvent, makeLocationEvent } from "../../test-utils/loc
describe("createMapSiteLinkFromEvent", () => {
it("returns null if event does not contain geouri", () => {
expect(createMapSiteLinkFromEvent(mkMessage({
room: '1', user: '@sender:server', event: true,
}))).toBeNull();
expect(
createMapSiteLinkFromEvent(
mkMessage({
room: "1",
user: "@sender:server",
event: true,
}),
),
).toBeNull();
});
it("returns OpenStreetMap link if event contains m.location", () => {
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",
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 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",
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",
);
});
});

View file

@ -30,128 +30,110 @@ describe("parseGeoUri", () => {
// these, but it is permitted, and we will fail to parse in that case.
it("rfc5870 6.1 Simple 3-dimensional", () => {
expect(parseGeoUri("geo:48.2010,16.3695,183")).toEqual(
{
latitude: 48.2010,
longitude: 16.3695,
altitude: 183,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
},
);
expect(parseGeoUri("geo:48.2010,16.3695,183")).toEqual({
latitude: 48.201,
longitude: 16.3695,
altitude: 183,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
});
});
it("rfc5870 6.2 Explicit CRS and accuracy", () => {
expect(parseGeoUri("geo:48.198634,16.371648;crs=wgs84;u=40")).toEqual(
{
latitude: 48.198634,
longitude: 16.371648,
altitude: undefined,
accuracy: 40,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
},
);
expect(parseGeoUri("geo:48.198634,16.371648;crs=wgs84;u=40")).toEqual({
latitude: 48.198634,
longitude: 16.371648,
altitude: undefined,
accuracy: 40,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
});
});
it("rfc5870 6.4 Negative longitude and explicit CRS", () => {
expect(parseGeoUri("geo:90,-22.43;crs=WGS84")).toEqual(
{
latitude: 90,
longitude: -22.43,
altitude: undefined,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
},
);
expect(parseGeoUri("geo:90,-22.43;crs=WGS84")).toEqual({
latitude: 90,
longitude: -22.43,
altitude: undefined,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
});
});
it("rfc5870 6.4 Integer lat and lon", () => {
expect(parseGeoUri("geo:90,46")).toEqual(
{
latitude: 90,
longitude: 46,
altitude: undefined,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
},
);
expect(parseGeoUri("geo:90,46")).toEqual({
latitude: 90,
longitude: 46,
altitude: undefined,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
});
});
it("rfc5870 6.4 Percent-encoded param value", () => {
expect(parseGeoUri("geo:66,30;u=6.500;FOo=this%2dthat")).toEqual(
{
latitude: 66,
longitude: 30,
altitude: undefined,
accuracy: 6.500,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
},
);
expect(parseGeoUri("geo:66,30;u=6.500;FOo=this%2dthat")).toEqual({
latitude: 66,
longitude: 30,
altitude: undefined,
accuracy: 6.5,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
});
});
it("rfc5870 6.4 Unknown param", () => {
expect(parseGeoUri("geo:66.0,30;u=6.5;foo=this-that>")).toEqual(
{
latitude: 66.0,
longitude: 30,
altitude: undefined,
accuracy: 6.5,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
},
);
expect(parseGeoUri("geo:66.0,30;u=6.5;foo=this-that>")).toEqual({
latitude: 66.0,
longitude: 30,
altitude: undefined,
accuracy: 6.5,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
});
});
it("rfc5870 6.4 Multiple unknown params", () => {
expect(parseGeoUri("geo:70,20;foo=1.00;bar=white")).toEqual(
{
latitude: 70,
longitude: 20,
altitude: undefined,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
},
);
expect(parseGeoUri("geo:70,20;foo=1.00;bar=white")).toEqual({
latitude: 70,
longitude: 20,
altitude: undefined,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
});
});
it("Negative latitude", () => {
expect(parseGeoUri("geo:-7.5,20")).toEqual(
{
latitude: -7.5,
longitude: 20,
altitude: undefined,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
},
);
expect(parseGeoUri("geo:-7.5,20")).toEqual({
latitude: -7.5,
longitude: 20,
altitude: undefined,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
});
});
it("Zero altitude is not unknown", () => {
expect(parseGeoUri("geo:-7.5,-20,0")).toEqual(
{
latitude: -7.5,
longitude: -20,
altitude: 0,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
},
);
expect(parseGeoUri("geo:-7.5,-20,0")).toEqual({
latitude: -7.5,
longitude: -20,
altitude: 0,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
});
});
});