Skip to content

Commit

Permalink
Use consistent coords property ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Jul 4, 2024
1 parent a637ff9 commit ff26f76
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ export function createUser({
normalizeCoordinates = ({
latitude = 0,
longitude = 0,
accuracy = 10,
altitude = null,
accuracy = 10,
altitudeAccuracy = null,
heading = null,
speed = null,
}) =>
createCoordinates({
latitude,
longitude,
accuracy,
altitude,
accuracy,
altitudeAccuracy,
heading,
speed,
Expand Down
4 changes: 2 additions & 2 deletions test/browser-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ function logPosition(
coords: {
latitude,
longitude,
accuracy,
altitude,
accuracy,
altitudeAccuracy,
heading,
speed,
Expand All @@ -22,8 +22,8 @@ function logPosition(
coords: {
latitude,
longitude,
accuracy,
altitude,
accuracy,
altitudeAccuracy,
heading,
speed,
Expand Down
8 changes: 4 additions & 4 deletions test/fixture/coords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { createCoordinates } from "fake-geolocation";
export const coordsA: GeolocationCoordinates = createCoordinates({
latitude: 40.71703581534977,
longitude: -74.03457283319447,
accuracy: 25.019,
altitude: 22.27227783203125,
accuracy: 25.019,
altitudeAccuracy: 9.838127136230469,
heading: null,
speed: null,
Expand All @@ -13,8 +13,8 @@ export const coordsA: GeolocationCoordinates = createCoordinates({
export const coordsB: GeolocationCoordinates = createCoordinates({
latitude: 12,
longitude: 34,
accuracy: 56,
altitude: 78,
accuracy: 56,
altitudeAccuracy: 9,
heading: null,
speed: null,
Expand All @@ -23,8 +23,8 @@ export const coordsB: GeolocationCoordinates = createCoordinates({
export const coordsC: GeolocationCoordinates = createCoordinates({
latitude: 98,
longitude: 76,
accuracy: 54,
altitude: 32,
accuracy: 54,
altitudeAccuracy: 10,
heading: null,
speed: null,
Expand All @@ -33,8 +33,8 @@ export const coordsC: GeolocationCoordinates = createCoordinates({
export const coordsD: GeolocationCoordinates = createCoordinates({
latitude: 23,
longitude: 45,
accuracy: 67,
altitude: 89,
accuracy: 67,
altitudeAccuracy: 10,
heading: null,
speed: null,
Expand Down
20 changes: 12 additions & 8 deletions test/vitest/create-coordinates.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { createCoordinates, GeolocationCoordinates } from "fake-geolocation";
import {
createCoordinates,
GeolocationCoordinates,
type GeolocationCoordinatesParameters,
} from "fake-geolocation";
import { describe, expect, it } from "vitest";

describe("createCoordinates()", () => {
describe("when all properties are provided", () => {
const properties = {
const properties: GeolocationCoordinatesParameters = {
latitude: 11,
longitude: 22,
altitude: 33,
accuracy: 44,
altitudeAccuracy: 55,
heading: 66,
speed: 77,
} as const;
};

it("creates coordinates", () => {
const coords = createCoordinates(properties);
Expand All @@ -31,11 +35,11 @@ describe("createCoordinates()", () => {
});

describe("when some properties are provided", () => {
const properties = {
const properties: Partial<GeolocationCoordinatesParameters> = {
latitude: 11,
longitude: 22,
accuracy: 33,
} as const;
};

it("creates coordinates", () => {
const coords = createCoordinates(properties);
Expand Down Expand Up @@ -73,15 +77,15 @@ describe("createCoordinates()", () => {
});

describe("when explicit undefined properties are provided", () => {
const properties = {
const properties: Partial<GeolocationCoordinatesParameters> = {
latitude: undefined,
longitude: undefined,
accuracy: undefined,
altitude: undefined,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
} as const;
};

it("creates coordinates", () => {
const coords = createCoordinates(properties);
Expand Down
2 changes: 1 addition & 1 deletion test/vitest/create-position.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ describe("createPosition()", () => {
const coordsProperties = {
latitude: undefined,
longitude: undefined,
accuracy: undefined,
altitude: undefined,
accuracy: undefined,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
Expand Down
8 changes: 4 additions & 4 deletions test/vitest/geolocation-coordinates.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ describe("GeolocationCoordinates", () => {
expect(coordinates.longitude).toBe(-74.03457283319447);
});

it("has an accuracy property", () => {
expect(coordinates.accuracy).toBe(25.019);
});

it("has an altitude property", () => {
expect(coordinates.altitude).toBe(22.27227783203125);
});

it("has an accuracy property", () => {
expect(coordinates.accuracy).toBe(25.019);
});

it("has an altitudeAccuracy property", () => {
expect(coordinates.altitudeAccuracy).toBe(9.838127136230469);
});
Expand Down
4 changes: 2 additions & 2 deletions test/vitest/geolocation-position.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ describe("GeolocationPosition", () => {
expect(position.coords).toMatchObject({
latitude: 40.71703581534977,
longitude: -74.03457283319447,
accuracy: 25.019,
altitude: 22.27227783203125,
accuracy: 25.019,
altitudeAccuracy: 9.838127136230469,
heading: 90,
speed: 111,
Expand All @@ -62,8 +62,8 @@ describe("GeolocationPosition", () => {
coords: {
latitude: 40.71703581534977,
longitude: -74.03457283319447,
accuracy: 25.019,
altitude: 22.27227783203125,
accuracy: 25.019,
altitudeAccuracy: 9.838127136230469,
heading: 90,
speed: 111,
Expand Down
4 changes: 2 additions & 2 deletions test/vitest/user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ describe("User", () => {
expect(await locationServices.acquireCoordinates(false)).toEqual({
latitude: 40.71703581534977,
longitude: -74.03457283319447,
accuracy: 111111,
altitude: 22.27227783203125,
accuracy: 111111,
altitudeAccuracy: 222222,
heading: null,
speed: null,
Expand All @@ -149,8 +149,8 @@ describe("User", () => {
expect(await locationServices.acquireCoordinates(true)).toEqual({
latitude: 0,
longitude: 0,
accuracy: 10,
altitude: null,
accuracy: 10,
altitudeAccuracy: null,
heading: null,
speed: null,
Expand Down

0 comments on commit ff26f76

Please sign in to comment.