Skip to content

Commit 3325edf

Browse files
committed
refactor: test files
1 parent a6d0962 commit 3325edf

File tree

3 files changed

+59
-42
lines changed

3 files changed

+59
-42
lines changed

tests/app.spec.tsx

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,16 @@
1-
import { describe, expect, test } from "vitest";
1+
import { describe, test } from "vitest";
22
import { render } from "vitest-browser-react";
33
import App from "../src/app";
44
import { Provider } from "../src/components/ui/provider";
55

6-
function renderApp(path?: string) {
7-
window.history.pushState({}, "", path || "");
6+
function renderApp() {
87
return render(
98
<Provider>
109
<App></App>
1110
</Provider>,
1211
);
1312
}
1413

15-
describe("initial state", () => {
16-
test("renders example button", async () => {
17-
const app = renderApp();
18-
await expect
19-
.element(app.getByRole("button", { name: "examples" }))
20-
.toBeVisible();
21-
});
22-
});
23-
24-
describe("loading", () => {
25-
test("stac.eoapi.dev", async () => {
26-
const app = renderApp("?href=https://stac.eoapi.dev/");
27-
await expect.element(app.getByText(/eoAPI-stac/i)).toBeVisible();
28-
await expect.element(app.getByText(/collections/i)).toBeVisible();
29-
30-
await app.getByRole("heading", { name: "Afghanistan Earthquake" }).click();
31-
expect(new URL(window.location.href).search).toBe(
32-
"?href=https://stac.eoapi.dev/collections/MAXAR_afghanistan_earthquake22",
33-
);
34-
});
35-
36-
test("CSDA Planet", async () => {
37-
// https://github.com/developmentseed/stac-map/issues/96
38-
const app = renderApp(
39-
"?href=https://csdap.earthdata.nasa.gov/stac/collections/planet",
40-
);
41-
await expect
42-
.element(app.getByRole("heading", { name: "Planet" }))
43-
.toBeVisible();
44-
});
45-
46-
test("NAIP stac-geoparquet", async () => {
47-
const app = renderApp(
48-
"?href=https://raw.githubusercontent.com/developmentseed/labs-375-stac-geoparquet-backend/refs/heads/main/data/naip.parquet",
49-
);
50-
await expect.element(app.getByText(/stac-geoparquet/i)).toBeVisible();
51-
});
52-
});
53-
5414
describe("navigation", () => {
5515
test("static catalog", async () => {
5616
const app = renderApp();

tests/header.spec.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { describe, expect, test } from "vitest";
2+
import { Provider } from "../src/components/ui/provider";
3+
import { render } from "vitest-browser-react";
4+
import App from "../src/app";
5+
6+
function renderApp() {
7+
return render(
8+
<Provider>
9+
<App></App>
10+
</Provider>,
11+
);
12+
}
13+
14+
describe("initial state", () => {
15+
test("renders example button", async () => {
16+
const app = renderApp();
17+
await expect
18+
.element(app.getByRole("button", { name: "examples" }))
19+
.toBeVisible();
20+
});
21+
});

tests/panel.spec.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { describe, expect, test } from "vitest";
2+
import { render } from "vitest-browser-react";
3+
import App from "../src/app";
4+
import { Provider } from "../src/components/ui/provider";
5+
6+
function renderApp(path?: string) {
7+
window.history.pushState({}, "", path || "");
8+
return render(
9+
<Provider>
10+
<App></App>
11+
</Provider>,
12+
);
13+
}
14+
15+
describe("loading", () => {
16+
test("stac.eoapi.dev", async () => {
17+
const app = renderApp("?href=https://stac.eoapi.dev/");
18+
await expect.element(app.getByText(/eoAPI-stac/i)).toBeVisible();
19+
await expect.element(app.getByText(/collections/i)).toBeVisible();
20+
21+
await app.getByRole("heading", { name: "Afghanistan Earthquake" }).click();
22+
expect(new URL(window.location.href).search).toBe(
23+
"?href=https://stac.eoapi.dev/collections/MAXAR_afghanistan_earthquake22",
24+
);
25+
});
26+
27+
test("CSDA Planet", async () => {
28+
// https://github.com/developmentseed/stac-map/issues/96
29+
const app = renderApp(
30+
"?href=https://csdap.earthdata.nasa.gov/stac/collections/planet",
31+
);
32+
await expect
33+
.element(app.getByRole("heading", { name: "Planet" }))
34+
.toBeVisible();
35+
});
36+
});

0 commit comments

Comments
 (0)