Skip to content

test: ⚡ Made tests concurrent #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/AccessControlLayer.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { queryAccessControl } from "../src/layers/AccessControlLayer.js";
import Point from "@arcgis/core/geometry/Point.js";
import SpatialReference from "@arcgis/core/geometry/SpatialReference.js";
import { expect, describe, test } from "vitest";
import { describe, test } from "vitest";

describe("AccessControlLayer", () => {
test("query", async () => {
describe.concurrent("AccessControlLayer", () => {
test("query", async ({ expect }) => {
const [x, y] = [-13377854.691900361, 6068328.6911837095];
const point = new Point({
x,
Expand Down
10 changes: 6 additions & 4 deletions tests/GeoUri.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Generated by CodiumAI, then modified
import GeoUrl, { CrsLabel } from "../src/urls/GeoUri";
import { describe, expect, it } from "vitest";
import { describe, it } from "vitest";

describe("GeoURI", () => {
describe.concurrent("GeoURI", () => {
// Should construct a GeoUrl object with valid options
it("should construct a GeoUrl object with all valid options", () => {
it("should construct a GeoUrl object with all valid options", ({
expect,
}) => {
// Test input
const options = {
x: 1,
Expand Down Expand Up @@ -35,7 +37,7 @@ describe("GeoURI", () => {
expect(geoUrl.latLngTuple).toEqual([expectedY, expectedX]);
expect(geoUrl.xyTuple).toEqual([expectedX, expectedY]);
});
it("should construct a GeoUrl object with valid options", () => {
it("should construct a GeoUrl object with valid options", ({ expect }) => {
// Test input
const options = {
x: 1,
Expand Down
64 changes: 33 additions & 31 deletions tests/Geohack.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createGeoHackUrl } from "../src/urls/geohack";
import { createGeoHackAnchor } from "../src/urls/geohack/createGeoHackAnchor";
import { expect, test } from "vitest";
import { suite, test } from "vitest";

function createExpectedUrl(lat: number, lng: number) {
// Create regex to account for URL encoding of ";" character.
Expand All @@ -9,39 +9,41 @@ function createExpectedUrl(lat: number, lng: number) {
);
}

test("create geohack URL with a tuple", () => {
const coordinates = [45.6448, -122.6617] as const;
const url = createGeoHackUrl({
params: {
coordinates,
},
suite.concurrent("geohack", () => {
test("create geohack URL with a tuple", ({ expect }) => {
const coordinates = [45.6448, -122.6617] as const;
const url = createGeoHackUrl({
params: {
coordinates,
},
});
// Create regex to account for URL encoding of ";" character.
const expectedRe = createExpectedUrl(...coordinates);
expect(url.href).toMatch(expectedRe);
});
// Create regex to account for URL encoding of ";" character.
const expectedRe = createExpectedUrl(...coordinates);
expect(url.href).toMatch(expectedRe);
});

test("create geohack URL with an object", () => {
const latLng = { lat: 45.6448, lng: -122.6617 };
const url = createGeoHackUrl({
params: {
coordinates: latLng,
},
test("create geohack URL with an object", ({ expect }) => {
const latLng = { lat: 45.6448, lng: -122.6617 };
const url = createGeoHackUrl({
params: {
coordinates: latLng,
},
});
// Create regex to account for URL encoding of ";" character.
const expectedRe = createExpectedUrl(latLng.lat, latLng.lng);
expect(url.href).toMatch(expectedRe);
});
// Create regex to account for URL encoding of ";" character.
const expectedRe = createExpectedUrl(latLng.lat, latLng.lng);
expect(url.href).toMatch(expectedRe);
});

test("create geohack anchor", () => {
const latLng = [45.6448, -122.6617] as const;
const anchor = createGeoHackAnchor({
params: {
coordinates: latLng,
},
test("create geohack anchor", ({ expect }) => {
const latLng = [45.6448, -122.6617] as const;
const anchor = createGeoHackAnchor({
params: {
coordinates: latLng,
},
});
expect(anchor.href).toMatch(createExpectedUrl(...latLng));
expect(anchor.text).toBe("Geohack");
expect(anchor.target).toBe("_blank");
expect(anchor).toBeInstanceOf(HTMLAnchorElement);
});
expect(anchor.href).toMatch(createExpectedUrl(...latLng));
expect(anchor.text).toBe("Geohack");
expect(anchor.target).toBe("_blank");
expect(anchor).toBeInstanceOf(HTMLAnchorElement);
});
60 changes: 33 additions & 27 deletions tests/Github-link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,74 +9,80 @@ import {
getGithubPagesUrlFromGithubRepoUrl,
isGithubRepoUrl,
} from "../src/common/Github-Link";
import { expect, test, describe } from "vitest";
import { test, describe } from "vitest";

const pagesUrl = "https://wsdot-gis.github.io/wsdot-mp-map";
const repoUrl = "https://github.com/WSDOT-GIS/wsdot-mp-map";

// Create regular expressions to match the expected responses.
const [pagesRe, repoRe] = [pagesUrl, repoUrl].map(
(url) =>
new RegExp(
// Add optional trailing slash.
String.raw`${url}\/?`
// Excape the periods so they won't match any character.
.replace(".", String.raw`\.`),
// Make case-insensitive
"i",
),
);
describe.concurrent("Github link", () => {
// Create regular expressions to match the expected responses.
const [pagesRe, repoRe] = [pagesUrl, repoUrl].map(
(url) =>
new RegExp(
// Add optional trailing slash.
String.raw`${url}\/?`
// Excape the periods so they won't match any character.
.replace(".", String.raw`\.`),
// Make case-insensitive
"i",
),
);

test("create github repo link", () => {
const outputUrl = getGithubUrlFromGithubPages(undefined, pagesUrl);
expect(outputUrl).toMatch(repoRe);
});
test("create github repo link", ({ expect }) => {
const outputUrl = getGithubUrlFromGithubPages(undefined, pagesUrl);
expect(outputUrl).toMatch(repoRe);
});

test("create github pages link", () => {
const outputUrl = getGithubPagesUrlFromGithubRepoUrl(undefined, repoUrl);
expect(outputUrl).toMatch(pagesRe);
test("create github pages link", ({ expect }) => {
const outputUrl = getGithubPagesUrlFromGithubRepoUrl(undefined, repoUrl);
expect(outputUrl).toMatch(pagesRe);
});
});

// Generated by CodiumAI

describe("isGithubRepoUrl", () => {
describe.concurrent("isGithubRepoUrl", () => {
// Returns true for a valid GitHub repository URL
test("should return true for a valid GitHub repository URL", () => {
test("should return true for a valid GitHub repository URL", ({ expect }) => {
const url = "https://github.com/org/repo";
const result = isGithubRepoUrl(url);
expect(result).toBe(true);
});

// Returns true for a valid GitHub repository URL with uppercase letters
test("should return true for a valid GitHub repository URL with uppercase letters", () => {
test("should return true for a valid GitHub repository URL with uppercase letters", ({
expect,
}) => {
const url = "https://github.com/ORG/REPO";
const result = isGithubRepoUrl(url);
expect(result).toBe(true);
});

// Returns true for a valid GitHub repository URL with numbers
test("should return true for a valid GitHub repository URL with numbers", () => {
test("should return true for a valid GitHub repository URL with numbers", ({
expect,
}) => {
const url = "https://github.com/org123/repo456";
const result = isGithubRepoUrl(url);
expect(result).toBe(true);
});

// Returns false for an empty string
test("should return false for an empty string", () => {
test("should return false for an empty string", ({ expect }) => {
const url = "";
const result = isGithubRepoUrl(url);
expect(result).toBe(false);
});

// Returns false for a URL with an invalid domain
test("should return false for a URL with an invalid domain", () => {
test("should return false for a URL with an invalid domain", ({ expect }) => {
const url = "https://example.com/org/repo";
const result = isGithubRepoUrl(url);
expect(result).toBe(false);
});

// Returns false for a URL with an invalid path
test("should return false for a URL with an invalid path", () => {
test("should return false for a URL with an invalid path", ({ expect }) => {
const url = "https://github.fake.cn/org/repo";
const result = isGithubRepoUrl(url);
expect(result).toBe(false);
Expand Down
6 changes: 3 additions & 3 deletions tests/Google.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { GoogleUrl } from "../src/urls/google";
import { expect, test, describe } from "vitest";
import { test, describe } from "vitest";

describe("GoogleUrl", () => {
test("fromLatLng", () => {
describe.concurrent("GoogleUrl", () => {
test("fromLatLng", ({ expect }) => {
const coords = [47.14290824679381, -122.51220188959343] as const;
const url = GoogleUrl.fromLatLng(...coords);
expect(url.toString()).toBe(
Expand Down
6 changes: 3 additions & 3 deletions tests/LandSurveyLayer.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { querySectionTownship } from "../src/layers/LandSurveyLayer";
import Point from "@arcgis/core/geometry/Point";
import { describe, expect, test } from "vitest";
import { describe, test } from "vitest";

describe("LandSurveyLayer tests", () => {
test("querySectionTownship", async () => {
describe.concurrent("LandSurveyLayer tests", () => {
test("querySectionTownship", async ({ expect }) => {
const [x, y] = [-122.51220188959343, 47.14290824679381];
const point = new Point({ x, y, spatialReference: { wkid: 4326 } });
const features = await querySectionTownship({
Expand Down
14 changes: 7 additions & 7 deletions tests/WAExtent.test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { waExtent } from "../src/WAExtent";
import { describe, expect, it } from "vitest";
import { describe, it } from "vitest";

describe("waExtent", () => {
it("has the correct spatial reference", () => {
describe.concurrent("waExtent", () => {
it("has the correct spatial reference", ({ expect }) => {
expect(waExtent.spatialReference.isWebMercator).toBe(true);
});

it("has the correct xmin value", () => {
it("has the correct xmin value", ({ expect }) => {
expect(waExtent.xmin).toBeCloseTo(-13891559.256092377);
});

it("has the correct ymin value", () => {
it("has the correct ymin value", ({ expect }) => {
expect(waExtent.ymin).toBeCloseTo(5706937.852318744);
});

it("has the correct xmax value", () => {
it("has the correct xmax value", ({ expect }) => {
expect(waExtent.xmax).toBeCloseTo(-13014361.668641392);
});

it("has the correct ymax value", () => {
it("has the correct ymax value", ({ expect }) => {
expect(waExtent.ymax).toBeCloseTo(6283349.610269844);
});
});
8 changes: 4 additions & 4 deletions tests/colors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import {
highwaySignTextColor,
} from "../src/colors.js";
import Color from "@arcgis/core/Color.js";
import { expect, test, describe } from "vitest";
import { test, describe } from "vitest";

describe("colors", () => {
test("highwaySignBackgroundColor", () => {
describe.concurrent("colors", () => {
test("highwaySignBackgroundColor", ({ expect }) => {
expect(highwaySignBackgroundColor).toBeInstanceOf(Color);
});
test("highwaySignTextColor", () => {
test("highwaySignTextColor", ({ expect }) => {
expect(highwaySignTextColor).toBeInstanceOf(Color);
});
});
14 changes: 8 additions & 6 deletions tests/elc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
import { hasXAndY } from "../src/types";
import Graphic from "@arcgis/core/Graphic";
import Point from "@arcgis/core/geometry/Point";
import { expect, describe, test } from "vitest";
import { describe, test } from "vitest";

describe("elc", () => {
test("findNearestRouteLocations", async () => {
describe.concurrent("elc", () => {
test("findNearestRouteLocations", async ({ expect }) => {
const options: FindNearestRouteLocationParameters = {
coordinates: [1083893.182, 111526.885],
inSR: 2927,
Expand Down Expand Up @@ -103,7 +103,7 @@ describe("elc", () => {
}
});

test("getRoutes", async () => {
test("getRoutes", async ({ expect }) => {
const result = await getRoutes();
expect(result).not.toBeNull();
expect(result).toHaveProperty("Current");
Expand All @@ -112,8 +112,10 @@ describe("elc", () => {
});
});

describe("arcgis", () => {
test("creates a Graphic with correct geometry from a valid RouteLocation", () => {
describe.concurrent("arcgis", () => {
test("creates a Graphic with correct geometry from a valid RouteLocation", ({
expect,
}) => {
const routeLocation: RouteLocation<DateString, RouteGeometryPoint> = {
RouteGeometry: {
x: -122.431297,
Expand Down
6 changes: 3 additions & 3 deletions tests/export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import arcgisSample from "./mileposts-sample.arcgis.json";
// TODO: figure out how to import using correct ".geojson" extension.
import geoJsonSample from "./mileposts-sample.geojson.json";
import FeatureSet from "@arcgis/core/rest/support/FeatureSet";
import { describe, expect, test } from "vitest";
import { describe, test } from "vitest";

describe("ArcGIS to GeoJSON export", () => {
test("test", () => {
describe.concurrent("ArcGIS to GeoJSON export", () => {
test("test", ({ expect }) => {
const featureSet = FeatureSet.fromJSON(arcgisSample);
const actualGeoJsonFeatureCollection =
convertArcGisFeatureSetToGeoJson(featureSet);
Expand Down
6 changes: 3 additions & 3 deletions tests/hash.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { parseMapPositionHash } from "../src/history-api";
import { test, expect, describe } from "vitest";
import { test, describe } from "vitest";

describe("parseMapPositionHash", () => {
test("Can parse hash without search parameters", () => {
describe.concurrent("parseMapPositionHash", () => {
test("Can parse hash without search parameters", ({ expect }) => {
const url = "http://path/to/my/page.html#map=2.59/39.26/53.07/-24.1/60";

const expected = {
Expand Down
6 changes: 3 additions & 3 deletions tests/history-api/url-search.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { moveUrlSearchToHash } from "../../src/history-api/url-search";
import { test, expect, describe } from "vitest";
import { test, describe } from "vitest";

describe("moveUrlSearchToHash", () => {
test("moves the URL search parameters to the URL hash", () => {
describe.concurrent("moveUrlSearchToHash", () => {
test("moves the URL search parameters to the URL hash", ({ expect }) => {
const x = -122.90913367530709;
const y = 46.14502682037163;
const zoom = 15;
Expand Down
6 changes: 3 additions & 3 deletions tests/milepost-info.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getRouteList } from "../src/milepost-info";
import { describe, it, expect } from "vitest";
import { describe, it } from "vitest";

// create test suite to test getRouteList function
describe("getRouteList", () => {
it("should return a list of routes", async () => {
describe.concurrent("getRouteList", () => {
it("should return a list of routes", async ({ expect }) => {
const routes = await getRouteList();
expect(routes.length).toBeGreaterThan(0);
for (const { RouteID, Direction, MinSrmp, MaxSrmp } of routes) {
Expand Down
Loading