-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#17 Validation proxy fails for field name "value"
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
packages/pure-validations-react/src/validationProxy/__tests__/validationProxy.tests.js
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,30 @@ | ||
import { ValidationProxy, eject } from "../"; | ||
import { Success, Failure, ValidationError } from "@totalsoft/pure-validations"; | ||
|
||
|
||
jest.unmock("@totalsoft/pure-validations"); | ||
|
||
describe("validation proxy", () => { | ||
it("returns inner validation", () => { | ||
// Arrange | ||
const validation = Failure(ValidationError("", { value: ValidationError("Error") })) | ||
const proxy = ValidationProxy(validation) | ||
|
||
// Act | ||
const innerValidation = eject(proxy.value); | ||
|
||
// Assert | ||
expect(innerValidation).toStrictEqual(Failure(ValidationError("Error"))) | ||
}); | ||
it("returns success if inner validation not found", () => { | ||
// Arrange | ||
const validation = Success | ||
const proxy = ValidationProxy(validation) | ||
|
||
// Act | ||
const innerValidation = eject(proxy.value); | ||
|
||
// Assert | ||
expect(innerValidation).toBe(Success) | ||
}); | ||
}) |
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