diff --git a/tests/AccessControlLayer.test.ts b/tests/AccessControlLayer.test.ts index 420fb271..4afe2e09 100644 --- a/tests/AccessControlLayer.test.ts +++ b/tests/AccessControlLayer.test.ts @@ -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, diff --git a/tests/GeoUri.test.ts b/tests/GeoUri.test.ts index a84c2d71..7f1b02e2 100644 --- a/tests/GeoUri.test.ts +++ b/tests/GeoUri.test.ts @@ -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, @@ -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, diff --git a/tests/Geohack.test.ts b/tests/Geohack.test.ts index 7fcb89dd..0937c699 100644 --- a/tests/Geohack.test.ts +++ b/tests/Geohack.test.ts @@ -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. @@ -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); }); diff --git a/tests/Github-link.test.ts b/tests/Github-link.test.ts index 4d4ed30b..151357f2 100644 --- a/tests/Github-link.test.ts +++ b/tests/Github-link.test.ts @@ -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); diff --git a/tests/Google.test.ts b/tests/Google.test.ts index 344e8983..bea4dba5 100644 --- a/tests/Google.test.ts +++ b/tests/Google.test.ts @@ -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( diff --git a/tests/LandSurveyLayer.test.ts b/tests/LandSurveyLayer.test.ts index b941106b..f539e7c0 100644 --- a/tests/LandSurveyLayer.test.ts +++ b/tests/LandSurveyLayer.test.ts @@ -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({ diff --git a/tests/WAExtent.test.ts b/tests/WAExtent.test.ts index 05c57d23..c39dcec8 100644 --- a/tests/WAExtent.test.ts +++ b/tests/WAExtent.test.ts @@ -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); }); }); diff --git a/tests/colors.test.ts b/tests/colors.test.ts index 77ae98fa..d9f5c325 100644 --- a/tests/colors.test.ts +++ b/tests/colors.test.ts @@ -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); }); }); diff --git a/tests/elc.test.ts b/tests/elc.test.ts index 0e21b0c3..6710b128 100644 --- a/tests/elc.test.ts +++ b/tests/elc.test.ts @@ -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, @@ -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"); @@ -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 = { RouteGeometry: { x: -122.431297, diff --git a/tests/export.test.ts b/tests/export.test.ts index 2b2a0d86..7953d16b 100644 --- a/tests/export.test.ts +++ b/tests/export.test.ts @@ -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); diff --git a/tests/hash.test.ts b/tests/hash.test.ts index 03fc3192..5d521662 100644 --- a/tests/hash.test.ts +++ b/tests/hash.test.ts @@ -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 = { diff --git a/tests/history-api/url-search.test.ts b/tests/history-api/url-search.test.ts index 2356d290..24c13f8a 100644 --- a/tests/history-api/url-search.test.ts +++ b/tests/history-api/url-search.test.ts @@ -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; diff --git a/tests/milepost-info.test.ts b/tests/milepost-info.test.ts index ad678917..cf4a12a8 100644 --- a/tests/milepost-info.test.ts +++ b/tests/milepost-info.test.ts @@ -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) { diff --git a/tests/padRoutes.test.ts b/tests/padRoutes.test.ts index a5120029..d9b6bb92 100644 --- a/tests/padRoutes.test.ts +++ b/tests/padRoutes.test.ts @@ -1,46 +1,56 @@ import { padRoute } from "../src/utils"; -import { describe, expect, it } from "vitest"; +import { describe, it } from "vitest"; // Generated by CodiumAI -describe("padRoute", () => { +describe.concurrent("padRoute", () => { // Should return the same input if it is a three-digit number - it("should return the same input when the input is a three-digit number", () => { + it("should return the same input when the input is a three-digit number", ({ + expect, + }) => { const input = "123"; const result = padRoute(input); expect(result).toBe(input); }); // Should pad a single-digit number with two leading zeros - it("should pad a single-digit number with two leading zeros", () => { + it("should pad a single-digit number with two leading zeros", ({ + expect, + }) => { const input = "1"; const result = padRoute(input); expect(result).toBe("001"); }); // Should pad a double-digit number with one leading zero - it("should pad a double-digit number with one leading zero", () => { + it("should pad a double-digit number with one leading zero", ({ expect }) => { const input = "12"; const result = padRoute(input); expect(result).toBe("012"); }); // Should pad a string with leading zeros if it is a single-digit number with leading zeros - it("should pad a string with leading zeros if it is a single-digit number with leading zeros", () => { + it("should pad a string with leading zeros if it is a single-digit number with leading zeros", ({ + expect, + }) => { const input = "0001"; const result = padRoute(input); expect(result).toBe("0001"); }); // Should return the same input if it is a string with leading zeros and more than two digits - it("should return the same input if it is a string with leading zeros and more than two digits", () => { + it("should return the same input if it is a string with leading zeros and more than two digits", ({ + expect, + }) => { const input = "000123"; const result = padRoute(input); expect(result).toBe("000123"); }); // Should return the same input if it is a string with leading zeros and non-numeric characters - it("should return the same input if it is a string with leading zeros and non-numeric characters", () => { + it("should return the same input if it is a string with leading zeros and non-numeric characters", ({ + expect, + }) => { const input = "00abc"; const result = padRoute(input); expect(result).toBe("00abc"); diff --git a/tests/url.test.ts b/tests/url.test.ts index e0427e37..dbb3f3dc 100644 --- a/tests/url.test.ts +++ b/tests/url.test.ts @@ -1,5 +1,5 @@ import { getElcParamsFromUrl } from "../src/elc/url.js"; -import { describe, expect, test } from "vitest"; +import { describe, test } from "vitest"; const urlRoot = "https://example.com/data/tools/Locatemp/"; @@ -7,11 +7,11 @@ const urlRoot = "https://example.com/data/tools/Locatemp/"; // This is just to aid readability. type ExpectedType = Exclude, null>; -describe("URL search parameters", () => { +describe.concurrent("URL search parameters", () => { const today = new Date(); today.setHours(0, 0, 0, 0); - test("getElcParamsFromUrl", () => { + test("getElcParamsFromUrl", ({ expect }) => { const expected: ExpectedType = { Route: "005", Srmp: 123.45, @@ -24,7 +24,7 @@ describe("URL search parameters", () => { const actual = getElcParamsFromUrl(url); expect(actual).toEqual(expected); }); - test("AR specified", () => { + test("AR specified", ({ expect }) => { const p = new URLSearchParams([ ["SR", "503"], ["MP", "35.23"], @@ -57,7 +57,7 @@ describe("URL search parameters", () => { SR=20&mp=52&RT=SP goes to 020 @ MP 52, not the Spur (Anacortes) */ // Test URL creation when an Route Type is specified but not an RRQ. - test("Route Type specified", () => { + test("Route Type specified", ({ expect }) => { const p = new URLSearchParams([ ["SR", "20"], ["MP", "52"], @@ -80,8 +80,8 @@ describe("URL search parameters", () => { }); }); -describe("RRT w/o RRQ", () => { - test("getElcParamsFromUrl", async () => { +describe.concurrent("RRT w/o RRQ", () => { + test("getElcParamsFromUrl", async ({ expect }) => { const p = new URLSearchParams([ ["SR", "20"], ["MP", "52"],