Rename package from jrx to jfx

Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
2026-02-28 01:27:37 +00:00
parent b8d1d2de80
commit 2f9e0a9936
21 changed files with 144 additions and 148 deletions

View File

@@ -1,11 +1,11 @@
/** @jsxImportSource react */
/**
* Integration tests: verify that Specs produced by jrx are consumable
* Integration tests: verify that Specs produced by jfx are consumable
* by @json-render/react's Renderer.
*
* This file uses React JSX (via the pragma above) for the React component
* tree, and jrx's jsx()/jsxs() via the component wrappers for building Specs.
* tree, and jfx's jsx()/jsxs() via the component wrappers for building Specs.
*/
import { describe, it, expect, mock } from "bun:test";
@@ -19,7 +19,7 @@ import {
} from "@json-render/react";
import { useStateStore } from "@json-render/react";
import { jsx, jsxs } from "./jsx-runtime";
import { render as jrxRender } from "./render";
import { render as jfxRender } from "./render";
import {
Stack as JStack,
Card as JCard,
@@ -64,7 +64,7 @@ function StateProbe() {
const registry = { Button, Text, Stack, Card };
// ---------------------------------------------------------------------------
// Helper: render a jrx spec with @json-render/react
// Helper: render a jfx spec with @json-render/react
// ---------------------------------------------------------------------------
function renderSpec(spec: Spec, handlers?: Record<string, (...args: unknown[]) => void>) {
@@ -80,15 +80,15 @@ function renderSpec(spec: Spec, handlers?: Record<string, (...args: unknown[]) =
// Basic rendering
// =============================================================================
describe("jrx → @json-render/react round-trip", () => {
describe("jfx → @json-render/react round-trip", () => {
it("renders a single element", () => {
const spec = jrxRender(jsx(JText, { content: "Hello from jrx" }));
const spec = jfxRender(jsx(JText, { content: "Hello from jfx" }));
renderSpec(spec);
expect(screen.getByTestId("text").textContent).toBe("Hello from jrx");
expect(screen.getByTestId("text").textContent).toBe("Hello from jfx");
});
it("renders nested elements with children", () => {
const spec = jrxRender(
const spec = jfxRender(
jsxs(JCard, {
title: "My Card",
children: [jsx(JText, { content: "Inside card" })],
@@ -101,7 +101,7 @@ describe("jrx → @json-render/react round-trip", () => {
});
it("renders a tree with multiple children", () => {
const spec = jrxRender(
const spec = jfxRender(
jsxs(JStack, {
children: [
jsx(JText, { content: "First" }),
@@ -116,7 +116,7 @@ describe("jrx → @json-render/react round-trip", () => {
});
it("renders a deep tree", () => {
const spec = jrxRender(
const spec = jfxRender(
jsxs(JStack, {
children: [
jsxs(JCard, {
@@ -136,9 +136,9 @@ describe("jrx → @json-render/react round-trip", () => {
// State + actions (adapted from chained-actions.test.tsx)
// =============================================================================
describe("jrx specs with state and actions", () => {
describe("jfx specs with state and actions", () => {
it("renders with initial state", () => {
const spec = jrxRender(jsx(JText, { content: "Stateful" }), {
const spec = jfxRender(jsx(JText, { content: "Stateful" }), {
state: { count: 42 },
});
renderSpec(spec);
@@ -148,7 +148,7 @@ describe("jrx specs with state and actions", () => {
});
it("setState action updates state on button press", async () => {
const spec = jrxRender(
const spec = jfxRender(
jsx(JButton, {
label: "Set",
on: {
@@ -172,7 +172,7 @@ describe("jrx specs with state and actions", () => {
});
it("chained pushState + setState resolves correctly", async () => {
const spec = jrxRender(
const spec = jfxRender(
jsx(JButton, {
label: "Chain",
on: {
@@ -206,7 +206,7 @@ describe("jrx specs with state and actions", () => {
});
it("multiple pushState chain resolves correctly", async () => {
const spec = jrxRender(
const spec = jfxRender(
jsx(JButton, {
label: "Go",
on: {
@@ -242,9 +242,9 @@ describe("jrx specs with state and actions", () => {
// Spec structural validity
// =============================================================================
describe("jrx spec structural validity", () => {
describe("jfx spec structural validity", () => {
it("all child references resolve to existing elements", () => {
const spec = jrxRender(
const spec = jfxRender(
jsxs(JStack, {
children: [
jsxs(JCard, {
@@ -272,12 +272,12 @@ describe("jrx spec structural validity", () => {
});
it("root element exists in elements map", () => {
const spec = jrxRender(jsx(JCard, { title: "Root" }));
const spec = jfxRender(jsx(JCard, { title: "Root" }));
expect(spec.elements[spec.root]).toBeDefined();
});
it("element count matches node count", () => {
const spec = jrxRender(
const spec = jfxRender(
jsxs(JStack, {
children: [
jsx(JCard, { title: "A" }),
@@ -294,9 +294,9 @@ describe("jrx spec structural validity", () => {
// Dynamic features (ported from json-render's dynamic-forms.test.tsx)
// =============================================================================
describe("jrx specs with dynamic features", () => {
describe("jfx specs with dynamic features", () => {
it("$state prop expressions resolve at render time", () => {
const spec = jrxRender(
const spec = jfxRender(
jsx(JText, { content: { $state: "/message" } }),
{ state: { message: "Dynamic hello" } },
);
@@ -306,7 +306,7 @@ describe("jrx specs with dynamic features", () => {
});
it("visibility condition hides element when false", () => {
const spec = jrxRender(
const spec = jfxRender(
jsxs(JStack, {
children: [
jsx(JText, {
@@ -324,7 +324,7 @@ describe("jrx specs with dynamic features", () => {
it("visibility condition shows element when true", () => {
cleanup();
const spec = jrxRender(
const spec = jfxRender(
jsxs(JStack, {
children: [
jsx(JText, {
@@ -343,7 +343,7 @@ describe("jrx specs with dynamic features", () => {
it("watchers fire when watched state changes", async () => {
const loadCities = mock();
const spec = jrxRender(
const spec = jfxRender(
jsxs(JStack, {
children: [
jsx(JButton, {