Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(remix-testing): stablize createRemixStub #7647

Merged
merged 8 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/perfect-lamps-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"remix": patch
"@remix-run/testing": patch
---

Remove the `unstable_` prefix from `createRemixStub`. After real-world experience, we're confident in the API and ready to commit to it.
22 changes: 11 additions & 11 deletions packages/remix-react/__tests__/integration/meta-test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meta, Outlet } from "@remix-run/react";
import { unstable_createRemixStub } from "@remix-run/testing";
import { createRemixStub } from "@remix-run/testing";
import { prettyDOM, render, screen } from "@testing-library/react";
import user from "@testing-library/user-event";
import * as React from "react";
Expand All @@ -9,7 +9,7 @@ const getHtml = (c: HTMLElement) =>

describe("meta", () => {
it("no meta export renders meta from nearest route meta in the tree", () => {
let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
id: "root",
path: "/",
Expand Down Expand Up @@ -66,7 +66,7 @@ describe("meta", () => {
});

it("empty meta array does not render a tag", () => {
let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
path: "/",
meta: () => [],
Expand All @@ -93,7 +93,7 @@ describe("meta", () => {
});

it("meta from `matches` renders meta tags", () => {
let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
id: "root",
path: "/",
Expand Down Expand Up @@ -141,7 +141,7 @@ describe("meta", () => {
});

it("{ charSet } adds a <meta charset='utf-8' />", () => {
let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
path: "/",
meta: () => [{ charSet: "utf-8" }],
Expand All @@ -161,7 +161,7 @@ describe("meta", () => {
});

it("{ title } adds a <title />", () => {
let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
path: "/",
meta: () => [{ title: "Document Title" }],
Expand All @@ -181,7 +181,7 @@ describe("meta", () => {
});

it("{ property: 'og:*', content: '*' } adds a <meta property='og:*' />", () => {
let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
path: "/",
meta: () => [
Expand Down Expand Up @@ -221,7 +221,7 @@ describe("meta", () => {
email: ["[email protected]", "[email protected]"],
};

let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
path: "/",
meta: () => [
Expand All @@ -244,7 +244,7 @@ describe("meta", () => {
});

it("{ tagName: 'link' } adds a <link />", () => {
let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
path: "/",
meta: () => [
Expand All @@ -270,7 +270,7 @@ describe("meta", () => {
});

it("does not mutate meta when using tagName", async () => {
let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
path: "/",
meta: ({ data }) => data?.meta,
Expand Down Expand Up @@ -329,7 +329,7 @@ describe("meta", () => {
});

it("loader errors are passed to meta", () => {
let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
path: "/",
Component() {
Expand Down
14 changes: 7 additions & 7 deletions packages/remix-testing/__tests__/stub-test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from "react";
import { render, screen } from "@testing-library/react";
import { unstable_createRemixStub } from "@remix-run/testing";
import { createRemixStub } from "@remix-run/testing";
import { Outlet, useLoaderData, useMatches } from "@remix-run/react";
import type { DataFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";

test("renders a route", () => {
let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
path: "/",
Component: () => <div>HOME</div>,
Expand All @@ -19,7 +19,7 @@ test("renders a route", () => {
});

test("renders a nested route", () => {
let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
Component() {
return (
Expand Down Expand Up @@ -50,7 +50,7 @@ test("loaders work", async () => {
return <pre data-testid="data">Message: {data.message}</pre>;
}

let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
path: "/",
index: true,
Expand All @@ -73,7 +73,7 @@ test("can pass a predefined loader", () => {
return json({ hi: "there" });
}

unstable_createRemixStub([
createRemixStub([
{
path: "/example",
loader,
Expand All @@ -97,7 +97,7 @@ test("can pass context values", async () => {
return <pre data-testid="hello">Context: {data.context}</pre>;
}

let RemixStub = unstable_createRemixStub(
let RemixStub = createRemixStub(
[
{
path: "/",
Expand Down Expand Up @@ -141,7 +141,7 @@ test("all routes have ids", () => {
);
}

let RemixStub = unstable_createRemixStub([
let RemixStub = createRemixStub([
{
Component() {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-testing/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export type { RemixStubProps } from "./create-remix-stub";
export { createRemixStub as unstable_createRemixStub } from "./create-remix-stub";
export { createRemixStub } from "./create-remix-stub";