purify-asserts
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -12,3 +12,3 @@ "use strict"; | ||
}; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./matchers"), exports); |
@@ -12,3 +12,3 @@ "use strict"; | ||
}; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./Maybe"), exports); |
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toHaveJustValue = exports.toBeNothing = exports.toBeJust = void 0; | ||
var pass = function (reason) { return ({ | ||
const pass = (reason) => ({ | ||
pass: true, | ||
message: function () { return reason; } | ||
}); }; | ||
var fail = function (reason) { return ({ | ||
message: () => reason, | ||
}); | ||
const fail = (reason) => ({ | ||
pass: false, | ||
message: function () { return reason; } | ||
}); }; | ||
message: () => reason, | ||
}); | ||
function toBeJust(actual) { | ||
return actual.caseOf({ | ||
Nothing: function () { return fail("Expected value to be Nothing but got Just instead"); }, | ||
Just: function (_) { return pass("Expected the value to be Just but got Nothing instead"); } | ||
Nothing: () => fail(`Expected value to be Nothing but got Just instead`), | ||
Just: (_) => pass(`Expected the value to be Just but got Nothing instead`), | ||
}); | ||
@@ -21,4 +21,4 @@ } | ||
return actual.caseOf({ | ||
Nothing: function () { return pass("Expected value to be Nothing but got Just instead"); }, | ||
Just: function (_) { return fail("Expected the value to be Just but got Nothing instead"); } | ||
Nothing: () => pass(`Expected value to be Nothing but got Just instead`), | ||
Just: (_) => fail(`Expected the value to be Just but got Nothing instead`), | ||
}); | ||
@@ -29,5 +29,5 @@ } | ||
return maybe.extract() === value | ||
? pass("Expected other than " + value + " but got " + maybe.toString()) | ||
: fail("Expected " + value + " but got " + maybe.toString()); | ||
? pass(`Expected other than ${value} but got ${maybe.toString()}`) | ||
: fail(`Expected ${value} but got ${maybe.toString()}`); | ||
} | ||
exports.toHaveJustValue = toHaveJustValue; |
@@ -21,15 +21,15 @@ "use strict"; | ||
}; | ||
exports.__esModule = true; | ||
var purify_ts_1 = require("purify-ts"); | ||
var matchers = __importStar(require("./")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const purify_ts_1 = require("purify-ts"); | ||
const matchers = __importStar(require("./")); | ||
expect.extend(matchers); | ||
describe("Maybe", function () { | ||
it(".toBeJust", function () { | ||
describe("Maybe", () => { | ||
it(".toBeJust", () => { | ||
expect(purify_ts_1.Maybe.fromNullable(1)).toBeJust(); | ||
expect((0, purify_ts_1.Just)(1)).toBeJust(); | ||
}); | ||
it(".not.toBeJust", function () { | ||
it(".not.toBeJust", () => { | ||
expect(purify_ts_1.Nothing).not.toBeJust(); | ||
}); | ||
it(".toBeNothing", function () { | ||
it(".toBeNothing", () => { | ||
expect(purify_ts_1.Maybe.fromNullable()).toBeNothing(); | ||
@@ -39,12 +39,12 @@ expect(purify_ts_1.Nothing).toBeNothing(); | ||
}); | ||
it(".not.toBeNothing", function () { | ||
it(".not.toBeNothing", () => { | ||
expect((0, purify_ts_1.Just)(1)).not.toBeNothing(); | ||
expect(purify_ts_1.List.head([1])).not.toBeNothing(); | ||
}); | ||
it(".toHaveJustValue", function () { | ||
it(".toHaveJustValue", () => { | ||
expect((0, purify_ts_1.Just)(1)).toHaveJustValue(1); | ||
}); | ||
it(".not.toHaveJustValue", function () { | ||
it(".not.toHaveJustValue", () => { | ||
expect((0, purify_ts_1.Just)(2)).not.toHaveJustValue(1); | ||
}); | ||
}); |
{ | ||
"name": "purify-asserts", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Jest expectations for the purify-ts library", | ||
"main": "index.js", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"repository": "https://github.com/nikoheikkila/purify-asserts", | ||
"author": "Niko Heikkilä <yo@nikoheikkila.fi>", | ||
"license": "MIT", | ||
"types": "src/jest.d.ts", | ||
"files": [ | ||
@@ -18,3 +18,4 @@ "dist" | ||
"build": "tsc", | ||
"release": "yarn build && np", | ||
"prerelease": "yarn build", | ||
"release": "np", | ||
"test": "jest", | ||
@@ -21,0 +22,0 @@ "lint": "prettier --check .", |
8585
11
124