-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add logic for boolean input; add tests
- Loading branch information
Showing
4 changed files
with
217 additions
and
36 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
kratos-admin-ui/src/components/traits/single-field.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
import { SingleField } from './single-field' | ||
import exp from 'constants' | ||
|
||
describe("test SingleField", () => { | ||
|
||
test("check boolean return value", async () => { | ||
|
||
const result = render(<SingleField | ||
fieldValues={ | ||
{ | ||
traits: { test: true }, | ||
publicMetadata: {}, | ||
adminMetadata: {}, | ||
state: 'active' | ||
} | ||
} | ||
setValues={() => { }} | ||
schemaField={ | ||
{ | ||
name: "test", | ||
format: "boolean", | ||
title: "test", | ||
fieldKind: 'trait', | ||
required: false, | ||
type: "boolean", | ||
subType: "boolean" | ||
} | ||
} | ||
/>) | ||
|
||
const checkbox: HTMLInputElement = result.container.querySelector("#checkbox-r0")!; | ||
expect(checkbox).toBeDefined(); | ||
expect(checkbox.checked).toBeTruthy(); | ||
}) | ||
|
||
test("check string value", async () => { | ||
|
||
const result = render(<SingleField | ||
fieldValues={ | ||
{ | ||
traits: { test: "jojojo" }, | ||
publicMetadata: {}, | ||
adminMetadata: {}, | ||
state: 'active' | ||
} | ||
} | ||
setValues={() => { }} | ||
schemaField={ | ||
{ | ||
name: "test", | ||
format: "email", | ||
title: "test", | ||
fieldKind: 'trait', | ||
required: true, | ||
type: "string", | ||
subType: "email" | ||
} | ||
} | ||
/>) | ||
|
||
const input: HTMLInputElement = result.container.querySelector("input")!; | ||
expect(input).toBeDefined(); | ||
expect(input.value).toBe("jojojo") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters