@nestia/e2e
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -10,2 +10,21 @@ /** | ||
/** | ||
* Test whether condition is satisfied. | ||
* | ||
* @param title Title of error message when condition is not satisfied | ||
* @return Currying function | ||
*/ | ||
const predicate: (title: string) => (condition: () => boolean) => void; | ||
/** | ||
* Test whether two values are equal. | ||
* | ||
* If you want to validate `covers` relationship, | ||
* call smaller first and then larger. | ||
* | ||
* Otherwise you wanna non equals validator, combine with {@link error}. | ||
* | ||
* @param title Title of error message when different | ||
* @returns Currying function | ||
*/ | ||
const equals: (title: string) => <T>(x: T) => (y: T) => void; | ||
/** | ||
* Test whether error occurs. | ||
@@ -21,9 +40,2 @@ * | ||
/** | ||
* Test whether two values are equal. | ||
* | ||
* @param title Title of error message when different | ||
* @returns Currying function | ||
*/ | ||
const equals: (title: string) => <T>(x: T) => (y: T) => void; | ||
/** | ||
* Validate index API. | ||
@@ -30,0 +42,0 @@ * |
@@ -52,4 +52,4 @@ "use strict"; | ||
var ranges_1 = require("tstl/ranges"); | ||
var RandomGenerator_1 = require("./RandomGenerator"); | ||
var json_equal_to_1 = require("./internal/json_equal_to"); | ||
var RandomGenerator_1 = require("./RandomGenerator"); | ||
/** | ||
@@ -66,2 +66,32 @@ * Test validator. | ||
/** | ||
* Test whether condition is satisfied. | ||
* | ||
* @param title Title of error message when condition is not satisfied | ||
* @return Currying function | ||
*/ | ||
TestValidator.predicate = function (title) { return function (condition) { | ||
if (condition() !== true) | ||
throw new Error("Bug on ".concat(title, ": expected condition is not satisfied.")); | ||
}; }; | ||
/** | ||
* Test whether two values are equal. | ||
* | ||
* If you want to validate `covers` relationship, | ||
* call smaller first and then larger. | ||
* | ||
* Otherwise you wanna non equals validator, combine with {@link error}. | ||
* | ||
* @param title Title of error message when different | ||
* @returns Currying function | ||
*/ | ||
TestValidator.equals = function (title) { | ||
return function (x) { | ||
return function (y) { | ||
var diff = (0, json_equal_to_1.json_equal_to)(x, y); | ||
if (diff.length) | ||
throw new Error("Bug on ".concat(title, ": found different values - [").concat(diff.join(", "), "]")); | ||
}; | ||
}; | ||
}; | ||
/** | ||
* Test whether error occurs. | ||
@@ -95,13 +125,2 @@ * | ||
/** | ||
* Test whether two values are equal. | ||
* | ||
* @param title Title of error message when different | ||
* @returns Currying function | ||
*/ | ||
TestValidator.equals = function (title) { return function (x) { return function (y) { | ||
var diff = (0, json_equal_to_1.json_equal_to)(x, y); | ||
if (diff.length) | ||
throw new Error("Bug on ".concat(title, ": found different values - [").concat(diff.join(", "), "]")); | ||
}; }; }; | ||
/** | ||
* Validate index API. | ||
@@ -108,0 +127,0 @@ * |
{ | ||
"name": "@nestia/e2e", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "E2E test utilify functions", | ||
@@ -10,3 +10,4 @@ "main": "lib/index.js", | ||
"prettier": "prettier --write ./src/**/*.ts", | ||
"test": "node lib/test" | ||
"test": "node lib/test", | ||
"prepare": "ts-patch install" | ||
}, | ||
@@ -37,3 +38,6 @@ "repository": { | ||
"rimraf": "^4.1.2", | ||
"typescript": "^4.9.5" | ||
"ts-node": "^10.9.1", | ||
"ts-patch": "^2.1.0", | ||
"typescript": "^4.9.5", | ||
"typia": "^3.6.9" | ||
}, | ||
@@ -40,0 +44,0 @@ "dependencies": { |
import { is_sorted } from "tstl/ranges"; | ||
import { json_equal_to } from "./internal/json_equal_to"; | ||
import { RandomGenerator } from "./RandomGenerator"; | ||
import { json_equal_to } from "./internal/json_equal_to"; | ||
@@ -15,2 +15,39 @@ /** | ||
/** | ||
* Test whether condition is satisfied. | ||
* | ||
* @param title Title of error message when condition is not satisfied | ||
* @return Currying function | ||
*/ | ||
export const predicate = (title: string) => (condition: () => boolean) => { | ||
if (condition() !== true) | ||
throw new Error( | ||
`Bug on ${title}: expected condition is not satisfied.`, | ||
); | ||
}; | ||
/** | ||
* Test whether two values are equal. | ||
* | ||
* If you want to validate `covers` relationship, | ||
* call smaller first and then larger. | ||
* | ||
* Otherwise you wanna non equals validator, combine with {@link error}. | ||
* | ||
* @param title Title of error message when different | ||
* @returns Currying function | ||
*/ | ||
export const equals = | ||
(title: string) => | ||
<T>(x: T) => | ||
(y: T) => { | ||
const diff: string[] = json_equal_to(x, y); | ||
if (diff.length) | ||
throw new Error( | ||
`Bug on ${title}: found different values - [${diff.join( | ||
", ", | ||
)}]`, | ||
); | ||
}; | ||
/** | ||
* Test whether error occurs. | ||
@@ -36,14 +73,2 @@ * | ||
/** | ||
* Test whether two values are equal. | ||
* | ||
* @param title Title of error message when different | ||
* @returns Currying function | ||
*/ | ||
export const equals = (title: string) => <T>(x: T) => (y: T) => { | ||
const diff: string[] = json_equal_to(x, y); | ||
if (diff.length) | ||
throw new Error(`Bug on ${title}: found different values - [${diff.join(", ")}]`); | ||
}; | ||
/** | ||
* Validate index API. | ||
@@ -50,0 +75,0 @@ * |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130418
2574
9