Skip to content

Commit

Permalink
+ cypress routeParams/suspense tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LankyMoose committed Apr 30, 2023
1 parent be06087 commit 8296517
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/lib/cypress/e2e/csr/context.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

describe("two-way-binding", () => {
describe("context", () => {
beforeEach(() => {
const port = Cypress.env("port")
cy.visit(`http://localhost:${port}/context`)
Expand Down
12 changes: 12 additions & 0 deletions packages/lib/cypress/e2e/csr/route-params.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference types="cypress" />

describe("route-params", () => {
beforeEach(() => {
const port = Cypress.env("port")
cy.visit(`http://localhost:${port}/nested-routing/test123`)
})

it("should display the route parameter value, 'test123'", () => {
cy.get("main h1").should("have.text", "test123")
})
})
2 changes: 1 addition & 1 deletion packages/lib/cypress/e2e/csr/signals.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

describe("two-way-binding", () => {
describe("signals", () => {
beforeEach(() => {
const port = Cypress.env("port")
cy.visit(`http://localhost:${port}`)
Expand Down
15 changes: 15 additions & 0 deletions packages/lib/cypress/e2e/csr/suspense.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// <reference types="cypress" />

describe("suspense", () => {
beforeEach(() => {
const port = Cypress.env("port")
cy.visit(`http://localhost:${port}/suspense`)
})

it("when the component renders, it should initially display a loading indicator", () => {
cy.get("main p").should("exist").should("have.text", "loading...")
})
it("when the component has loaded, it should display a list", () => {
cy.get("main ul").should("exist")
})
})
5 changes: 2 additions & 3 deletions packages/lib/src/router/router.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useRequestData } from "../ssr"
import { matchPath } from "."
import { Signal, Component } from ".."
import { Cinnabun } from "../cinnabun"
Expand Down Expand Up @@ -84,9 +85,7 @@ export const Router = (
const c = self.children[i] as RouteComponent
const matchRes = (self as RouterComponent).matchRoute(
c,
Cinnabun.isClient
? val
: self.cbInstance!.getServerRequestData<string>("path")!
useRequestData<string>(self, "path", val)!
)
if (matchRes.routeMatch) {
c.props.render = !!matchRes.routeMatch
Expand Down

0 comments on commit 8296517

Please sign in to comment.