mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-23 08:23:33 +10:00
chore: migrate from jsdom to happy-dom for testing environment
This commit is contained in:
@@ -4,5 +4,5 @@ import { createVitestProjectConfig } from "../../vitest.shared";
|
||||
export default createVitestProjectConfig({
|
||||
name: "@reactive-resume/email",
|
||||
dirname: fileURLToPath(new URL(".", import.meta.url)),
|
||||
environment: "jsdom",
|
||||
environment: "happy-dom",
|
||||
});
|
||||
|
||||
@@ -4,5 +4,5 @@ import { createVitestProjectConfig } from "../../vitest.shared";
|
||||
export default createVitestProjectConfig({
|
||||
name: "@reactive-resume/import",
|
||||
dirname: fileURLToPath(new URL(".", import.meta.url)),
|
||||
environment: "jsdom",
|
||||
environment: "happy-dom",
|
||||
});
|
||||
|
||||
@@ -107,7 +107,7 @@ describe("getResumeSectionTitle", () => {
|
||||
customSections: [
|
||||
{
|
||||
id: "ext-1",
|
||||
type: "cover-letter",
|
||||
type: "cover-letter" as const,
|
||||
title: "My Cover Letter",
|
||||
columns: 1,
|
||||
hidden: false,
|
||||
@@ -124,7 +124,7 @@ describe("getResumeSectionTitle", () => {
|
||||
customSections: [
|
||||
{
|
||||
id: "ext-1",
|
||||
type: "cover-letter",
|
||||
type: "cover-letter" as const,
|
||||
title: "",
|
||||
columns: 1,
|
||||
hidden: false,
|
||||
|
||||
@@ -138,8 +138,12 @@ describe("ComboboxCollection", () => {
|
||||
<ComboboxInput />
|
||||
<ComboboxContent>
|
||||
<ComboboxList>
|
||||
<ComboboxCollection items={items}>
|
||||
{(item) => <ComboboxItem value={item}>{item}</ComboboxItem>}
|
||||
<ComboboxCollection>
|
||||
{(item) => (
|
||||
<ComboboxItem key={item} value={item}>
|
||||
{item}
|
||||
</ComboboxItem>
|
||||
)}
|
||||
</ComboboxCollection>
|
||||
</ComboboxList>
|
||||
</ComboboxContent>
|
||||
|
||||
@@ -40,12 +40,12 @@ function FormLabel({ className, ...props }: React.ComponentProps<typeof Label>)
|
||||
);
|
||||
}
|
||||
|
||||
function FormControl(props: useRender.ComponentProps<"div">) {
|
||||
function FormControl({ render, ...props }: useRender.ComponentProps<"div">) {
|
||||
const { id, hasError } = useFormItem();
|
||||
|
||||
return useRender({
|
||||
...props,
|
||||
defaultTagName: "div",
|
||||
render,
|
||||
state: { slot: "form-control" },
|
||||
props: {
|
||||
id: `${id}-form-item`,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ResizableGroup, ResizablePanel, ResizableSeparator } from "./resizable"
|
||||
describe("ResizableGroup", () => {
|
||||
it("renders with data-slot='resizable-panel-group'", () => {
|
||||
const { container } = render(
|
||||
<ResizableGroup direction="horizontal">
|
||||
<ResizableGroup orientation="horizontal">
|
||||
<ResizablePanel>A</ResizablePanel>
|
||||
<ResizableSeparator />
|
||||
<ResizablePanel>B</ResizablePanel>
|
||||
@@ -16,7 +16,7 @@ describe("ResizableGroup", () => {
|
||||
|
||||
it("merges custom className", () => {
|
||||
const { container } = render(
|
||||
<ResizableGroup direction="horizontal" className="my-group">
|
||||
<ResizableGroup orientation="horizontal" className="my-group">
|
||||
<ResizablePanel>x</ResizablePanel>
|
||||
</ResizableGroup>,
|
||||
);
|
||||
@@ -27,7 +27,7 @@ describe("ResizableGroup", () => {
|
||||
describe("ResizablePanel", () => {
|
||||
it("renders with data-slot='resizable-panel'", () => {
|
||||
const { container } = render(
|
||||
<ResizableGroup direction="horizontal">
|
||||
<ResizableGroup orientation="horizontal">
|
||||
<ResizablePanel>x</ResizablePanel>
|
||||
</ResizableGroup>,
|
||||
);
|
||||
@@ -38,7 +38,7 @@ describe("ResizablePanel", () => {
|
||||
describe("ResizableSeparator", () => {
|
||||
it("renders with data-slot='resizable-handle' and no inner handle by default", () => {
|
||||
const { container } = render(
|
||||
<ResizableGroup direction="horizontal">
|
||||
<ResizableGroup orientation="horizontal">
|
||||
<ResizablePanel>A</ResizablePanel>
|
||||
<ResizableSeparator />
|
||||
<ResizablePanel>B</ResizablePanel>
|
||||
@@ -52,7 +52,7 @@ describe("ResizableSeparator", () => {
|
||||
|
||||
it("renders inner handle when withHandle=true", () => {
|
||||
const { container } = render(
|
||||
<ResizableGroup direction="horizontal">
|
||||
<ResizableGroup orientation="horizontal">
|
||||
<ResizablePanel>A</ResizablePanel>
|
||||
<ResizableSeparator withHandle />
|
||||
<ResizablePanel>B</ResizablePanel>
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
@@ -4,5 +4,5 @@ import { createVitestProjectConfig } from "../../vitest.shared";
|
||||
export default createVitestProjectConfig({
|
||||
name: "@reactive-resume/ui",
|
||||
dirname: fileURLToPath(new URL(".", import.meta.url)),
|
||||
environment: "jsdom",
|
||||
environment: "happy-dom",
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ describe("filterFieldValues", () => {
|
||||
|
||||
it("filters out fields with missing keys", () => {
|
||||
const fields = [{ key: "name" as const }];
|
||||
const result = filterFieldValues({}, ...fields);
|
||||
const result = filterFieldValues<"name", { key: "name" }>({}, ...fields);
|
||||
|
||||
expect(result.size).toBe(0);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @vitest-environment jsdom
|
||||
* @vitest-environment happy-dom
|
||||
*/
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { downloadFromUrl, downloadWithAnchor, generateFilename } from "./file";
|
||||
@@ -31,8 +31,8 @@ describe("generateFilename", () => {
|
||||
});
|
||||
|
||||
describe("downloadWithAnchor", () => {
|
||||
let createObjectURLSpy: ReturnType<typeof vi.fn>;
|
||||
let revokeObjectURLSpy: ReturnType<typeof vi.fn>;
|
||||
let createObjectURLSpy: ReturnType<typeof vi.fn<typeof URL.createObjectURL>>;
|
||||
let revokeObjectURLSpy: ReturnType<typeof vi.fn<typeof URL.revokeObjectURL>>;
|
||||
let originalCreate: typeof URL.createObjectURL;
|
||||
let originalRevoke: typeof URL.revokeObjectURL;
|
||||
|
||||
@@ -40,8 +40,8 @@ describe("downloadWithAnchor", () => {
|
||||
vi.useFakeTimers();
|
||||
originalCreate = URL.createObjectURL;
|
||||
originalRevoke = URL.revokeObjectURL;
|
||||
createObjectURLSpy = vi.fn(() => "blob:mock-url");
|
||||
revokeObjectURLSpy = vi.fn();
|
||||
createObjectURLSpy = vi.fn<typeof URL.createObjectURL>(() => "blob:mock-url");
|
||||
revokeObjectURLSpy = vi.fn<typeof URL.revokeObjectURL>();
|
||||
URL.createObjectURL = createObjectURLSpy;
|
||||
URL.revokeObjectURL = revokeObjectURLSpy;
|
||||
});
|
||||
@@ -91,8 +91,8 @@ describe("downloadWithAnchor", () => {
|
||||
|
||||
describe("downloadFromUrl", () => {
|
||||
let originalFetch: typeof global.fetch;
|
||||
let createObjectURLSpy: ReturnType<typeof vi.fn>;
|
||||
let revokeObjectURLSpy: ReturnType<typeof vi.fn>;
|
||||
let createObjectURLSpy: ReturnType<typeof vi.fn<typeof URL.createObjectURL>>;
|
||||
let revokeObjectURLSpy: ReturnType<typeof vi.fn<typeof URL.revokeObjectURL>>;
|
||||
let originalCreate: typeof URL.createObjectURL;
|
||||
let originalRevoke: typeof URL.revokeObjectURL;
|
||||
|
||||
@@ -100,8 +100,8 @@ describe("downloadFromUrl", () => {
|
||||
originalFetch = global.fetch;
|
||||
originalCreate = URL.createObjectURL;
|
||||
originalRevoke = URL.revokeObjectURL;
|
||||
createObjectURLSpy = vi.fn(() => "blob:mock-url");
|
||||
revokeObjectURLSpy = vi.fn();
|
||||
createObjectURLSpy = vi.fn<typeof URL.createObjectURL>(() => "blob:mock-url");
|
||||
revokeObjectURLSpy = vi.fn<typeof URL.revokeObjectURL>();
|
||||
URL.createObjectURL = createObjectURLSpy;
|
||||
URL.revokeObjectURL = revokeObjectURLSpy;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @vitest-environment jsdom
|
||||
* @vitest-environment happy-dom
|
||||
*/
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isObject, sanitizeCss, sanitizeHtml } from "./sanitize";
|
||||
|
||||
Reference in New Issue
Block a user