Skip to content

Commit 425ad42

Browse files
committed
fix: tests
1 parent 2a8d30f commit 425ad42

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

cmp/compiler/src/react/server-only/index.test.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/**
22
* @vitest-environment node
33
*/
4-
import { beforeEach, describe, expect, it, vi } from "vitest";
4+
import { assert, beforeEach, describe, expect, it, vi } from "vitest";
55
import React from "react";
6+
import { logger } from "../../utils/logger";
67

78
// Mock Next.js cookies
89
vi.mock("next/headers", () => ({
@@ -56,8 +57,10 @@ describe("Server-side rich text rendering", () => {
5657
a0: (chunks) => <a href="/home">{chunks}</a>,
5758
});
5859

59-
// Should return React element
60-
expect(React.isValidElement(result)).toBe(true);
60+
assert.isOk(Array.isArray(result));
61+
result.forEach((item) => {
62+
expect(React.isValidElement(item)).toBe(true);
63+
});
6164
});
6265

6366
it("should render mixed content with variables and components", async () => {
@@ -77,7 +80,10 @@ describe("Server-side rich text rendering", () => {
7780
},
7881
);
7982

80-
expect(React.isValidElement(result)).toBe(true);
83+
assert.isOk(Array.isArray(result));
84+
result.forEach((item) => {
85+
expect(React.isValidElement(item)).toBe(true);
86+
});
8187
});
8288

8389
it("should handle the page.tsx example case", async () => {
@@ -104,6 +110,9 @@ describe("Server-side rich text rendering", () => {
104110
},
105111
);
106112

107-
expect(React.isValidElement(result)).toBe(true);
113+
assert.isOk(Array.isArray(result));
114+
result.forEach((item) => {
115+
expect(React.isValidElement(item)).toBe(true);
116+
});
108117
});
109118
});

cmp/compiler/src/translators/parse-xml.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ describe("parseXmlFromResponseText", () => {
6565
products: "",
6666
prices: [1.99, 9.99],
6767
};
68-
// TODO (AleksandrSl 06/12/2025): Why tests parses the producs incorrectly here?
6968
expect(parseXmlFromResponseText(original)).toEqual(expected);
7069
});
7170

cmp/compiler/src/translators/parse-xml.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ function fromGenericNode(tag: string, data: any): any {
6262
if (data && typeof data === "object" && "#text" in data) {
6363
return data["#text"] ?? "";
6464
}
65+
// For self-closing tags like <value key="x" />, data is { key: "x" }
66+
// We should return empty string, not the attributes object
67+
if (data && typeof data === "object") {
68+
return "";
69+
}
6570
return data ?? "";
6671
}
6772

0 commit comments

Comments
 (0)