Skip to content

Commit

Permalink
#17 Validation proxy fails for field name "value"
Browse files Browse the repository at this point in the history
  • Loading branch information
fraliv13 committed Nov 1, 2019
1 parent c71f9f8 commit 83d9d3f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
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)
});
})
2 changes: 1 addition & 1 deletion packages/zion/src/data/maybe.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { equals, lte, map, concat } from "ramda";
//- When you want to get a value _out_, you must also deal with the
//- Nothing case, which prevents you from forgetting about it.

const Maybe = taggedSum("Maybe", { Just: ["value"], Nothing: [] });
const Maybe = taggedSum("Maybe", { Just: [Symbol("value")], Nothing: [] });

const { Just, Nothing } = Maybe;

Expand Down

0 comments on commit 83d9d3f

Please sign in to comment.