Skip to content

Commit

Permalink
chore: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas committed Jan 10, 2025
1 parent 6ca2e01 commit e8429c7
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`login footer should render correct sign up link 1`] = `
exports[`login footer should render return to in sign up link 1`] = `
<div>
<span
class="font-normal leading-normal antialiased text-interface-foreground-default-primary"
Expand All @@ -17,7 +17,24 @@ exports[`login footer should render correct sign up link 1`] = `
</div>
`;

exports[`registration footer should render correct sign in link 1`] = `
exports[`login footer should render sign up link 1`] = `
<div>
<span
class="font-normal leading-normal antialiased text-interface-foreground-default-primary"
>
Don't have an account?
<a
class="text-button-link-brand-brand transition-colors hover:text-button-link-brand-brand-hover underline"
href="http://localhost:4455/self-service/registration/browser"
>
Sign up
</a>
</span>
</div>
`;

exports[`registration footer should render return to in sign in link 1`] = `
<div>
<span
class="font-normal leading-normal antialiased"
Expand All @@ -33,3 +50,20 @@ exports[`registration footer should render correct sign in link 1`] = `
</span>
</div>
`;

exports[`registration footer should render sign in link 1`] = `
<div>
<span
class="font-normal leading-normal antialiased"
>
Already have an account?
<a
class="text-button-link-brand-brand transition-colors hover:text-button-link-brand-brand-hover underline"
href="http://localhost:4455/self-service/login/browser"
>
Sign in
</a>
</span>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ import { OryProvider } from "@ory/elements-react"
import { defaultConfiguration } from "../../../../tests/jest/test-utils"
import { DefaultCardFooter } from "./footer"

const flow = (returnTo?: string) => {
return {
request_url: `http://localhost:4455${returnTo ? "?return_to=" + returnTo : ""}`,
state: "",
ui: {
action: "",
method: "",
nodes: [],
messages: [],
},
} as unknown as LoginFlow
}

type renderProps = {
providerProps: ComponentProps<typeof OryProvider>
}
Expand All @@ -19,44 +32,51 @@ const renderWithContext = (
)
}

test("login footer should render correct sign up link", () => {
test("login footer should render return to in sign up link", () => {
const x = renderWithContext(<DefaultCardFooter />, {
providerProps: {
components: null!,
config: defaultConfiguration,
flowType: FlowType.Login,
flow: {
request_url: "http://localhost:4455?return_to=https://ory.sh",
state: "",
ui: {
action: "",
method: "",
nodes: [],
messages: [],
},
} as unknown as LoginFlow,
flow: flow("https://ory.sh"),
},
})

expect(x.container).toMatchSnapshot()
})

test("registration footer should render return to in sign in link", () => {
const x = renderWithContext(<DefaultCardFooter />, {
providerProps: {
components: null!,
config: defaultConfiguration,
flowType: FlowType.Registration,
flow: flow("https://ory.sh"),
},
})

expect(x.container).toMatchSnapshot()
})

test("registration footer should render correct sign in link", () => {
test("login footer should render sign up link", () => {
const x = renderWithContext(<DefaultCardFooter />, {
providerProps: {
components: null!,
config: defaultConfiguration,
flowType: FlowType.Login,
flow: flow(),
},
})

expect(x.container).toMatchSnapshot()
})
test("registration footer should render sign in link", () => {
const x = renderWithContext(<DefaultCardFooter />, {
providerProps: {
components: null!,
config: defaultConfiguration,
flowType: FlowType.Registration,
flow: {
request_url: "http://localhost:4455?return_to=https://ory.sh",
state: "",
ui: {
action: "",
method: "",
nodes: [],
messages: [],
},
} as unknown as LoginFlow,
flow: flow(),
},
})

Expand Down

0 comments on commit e8429c7

Please sign in to comment.