-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Setup hooks test + test array validation hook * Tests for array and common validation rules * Tests for date-time validation rules * Tests for email validation rule * Tests for number validation rules * Tests for text validation rules * Tests for uri validation rules * Tests for utils * Tests for utils * Fix some spelling errors * Rush change
- Loading branch information
Showing
19 changed files
with
643 additions
and
21 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
common/changes/@ilbrando/simple-form/simple-form-tests_2024-12-11-12-28.json
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,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@ilbrando/simple-form", | ||
"comment": "Implement tests", | ||
"type": "patch" | ||
} | ||
], | ||
"packageName": "@ilbrando/simple-form" | ||
} |
10 changes: 10 additions & 0 deletions
10
common/changes/@ilbrando/utils/simple-form-tests_2024-12-11-12-28.json
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,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@ilbrando/utils", | ||
"comment": "Fixed the type for getFieldValues", | ||
"type": "major" | ||
} | ||
], | ||
"packageName": "@ilbrando/utils" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
58 changes: 58 additions & 0 deletions
58
packages/simple-form/src/form-validation/validation-rules/array.test.ts
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,58 @@ | ||
import { describe, test } from "vitest"; | ||
import { renderHook } from "@testing-library/react"; | ||
|
||
import { useArrayValidationRules } from "./array"; | ||
import { assertValidationResult, genericErrorMessage } from "./validation-test-utils"; | ||
|
||
describe("array", () => { | ||
test.each` | ||
value | parameter | expected | ||
${[1, 2]} | ${1} | ${genericErrorMessage} | ||
${[1, 2]} | ${3} | ${genericErrorMessage} | ||
${[1, 2]} | ${2} | ${undefined} | ||
${[]} | ${0} | ${undefined} | ||
`("count($parameter)($value) => $expected", ({ value, parameter, expected }) => { | ||
// Arrange | ||
const { result } = renderHook(() => useArrayValidationRules()); | ||
|
||
// Act | ||
const actual = result.current.count(parameter)(value); | ||
|
||
// Assert | ||
assertValidationResult(expected, actual); | ||
}); | ||
|
||
test.each` | ||
value | parameter | expected | ||
${[1, 2]} | ${1} | ${genericErrorMessage} | ||
${[1, 2]} | ${3} | ${undefined} | ||
${[1, 2]} | ${2} | ${undefined} | ||
${[]} | ${0} | ${undefined} | ||
`("maxCount($parameter)($value) => $expected", ({ value, parameter, expected }) => { | ||
// Arrange | ||
const { result } = renderHook(() => useArrayValidationRules()); | ||
|
||
// Act | ||
const actual = result.current.maxCount(parameter)(value); | ||
|
||
// Assert | ||
assertValidationResult(expected, actual); | ||
}); | ||
|
||
test.each` | ||
value | parameter | expected | ||
${[1, 2]} | ${1} | ${undefined} | ||
${[1, 2]} | ${3} | ${genericErrorMessage} | ||
${[1, 2]} | ${2} | ${undefined} | ||
${[]} | ${0} | ${undefined} | ||
`("minCount($parameter)($value) => $expected", ({ value, parameter, expected }) => { | ||
// Arrange | ||
const { result } = renderHook(() => useArrayValidationRules()); | ||
|
||
// Act | ||
const actual = result.current.minCount(parameter)(value); | ||
|
||
// Assert | ||
assertValidationResult(expected, actual); | ||
}); | ||
}); |
Oops, something went wrong.