Skip to content

Commit

Permalink
Add test for React Strict Mode support (bitovi#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
chez14 committed Jan 30, 2024
1 parent 3ce1656 commit 9f0bca3
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ describe("react-to-web-component 1", () => {
expect(div?.textContent).toBe("hello, Bavin")
})

it("works with props array in strict mode", async () => {
function TestComponent({ name }: { name: string }) {
return <div>hello, {name}</div>
}

const TestElement = r2wc(TestComponent, { props: ["name"], strictMode: true })

customElements.define("test-hello-strict", TestElement)

const body = document.body
body.innerHTML = "<test-hello-strict name='Bavin'></test-hello>"

await flushPromises()

const div = body.querySelector("div")
expect(div?.textContent).toBe("hello, Bavin")
})

it("works with proptypes", async () => {
function WithProptypes({ name }: { name: string }) {
return <div>hello, {name}</div>
Expand Down

0 comments on commit 9f0bca3

Please sign in to comment.