Skip to content

Commit

Permalink
chore: add more missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas committed Nov 18, 2024
1 parent 0a8712b commit 511d6fc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/elements-react/src/context/form-state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ test('should initialize with "provide_identifier" state', () => {
expect(state).toEqual({ current: "provide_identifier" })
})

test('should initialize with "settings" state for settings flows', () => {
const { result } = renderHook(() =>
useFormStateReducer({
flowType: FlowType.Settings,
} as unknown as OryFlowContainer),
)

const [state] = result.current
expect(state).toEqual({ current: "settings" })
})

test('should transition to "method_active" state when "action_select_method" is dispatched', () => {
const { result } = renderHook(() => useFormStateReducer(init))
const [, dispatch] = result.current
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { omit } from "../attributes"

test("deletes keys from object", () => {
const obj = {
a: 1,
b: 2,
c: 3,
}
const result = omit(obj, ["a", "c"])
expect(result).toEqual({ b: 2 })
})

test("ignores unknown keys", () => {
const obj = {
a: 1,
b: 2,
c: 3,
}
const result = omit(obj, ["a", "x"] as (keyof typeof obj)[])
expect(result).toEqual({ b: 2, c: 3 })
})

test("returns object if keys are empty", () => {
const obj = {
a: 1,
b: 2,
c: 3,
}
const result = omit(obj, [])
expect(result).toEqual({ a: 1, b: 2, c: 3 })
})

0 comments on commit 511d6fc

Please sign in to comment.