type-enforcer-test-helper 1.3.10 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +2 -156
  2. package/dist/js/index.js +7 -0
  3. package/dist/js/src/data/TestClass.js +12 -0
  4. package/dist/js/src/data/coercible.js +81 -0
  5. package/dist/js/src/data/testData.js +168 -0
  6. package/dist/js/src/data/testValues.js +116 -0
  7. package/dist/js/src/multiTest.js +116 -0
  8. package/dist/js/src/testCheck.js +39 -0
  9. package/dist/js/src/testEnforce.js +121 -0
  10. package/dist/js/src/testMethod.js +337 -0
  11. package/dist/js/src/utility/difference.js +7 -0
  12. package/dist/types/index.d.ts +7 -0
  13. package/dist/types/src/data/TestClass.d.ts +6 -0
  14. package/dist/types/src/data/coercible.d.ts +6 -0
  15. package/dist/types/src/data/testData.d.ts +30 -0
  16. package/dist/types/src/data/testData.test.d.ts +1 -0
  17. package/dist/types/src/data/testValues.d.ts +19 -0
  18. package/dist/types/src/data/testValues.test.d.ts +1 -0
  19. package/dist/types/src/multiTest.d.ts +58 -0
  20. package/dist/types/src/multiTest.test.d.ts +1 -0
  21. package/dist/types/src/testCheck.d.ts +3 -0
  22. package/dist/types/src/testCheck.test.d.ts +1 -0
  23. package/dist/types/src/testEnforce.d.ts +2 -0
  24. package/dist/types/src/testEnforce.test.d.ts +1 -0
  25. package/dist/types/src/testMethod.d.ts +20 -0
  26. package/dist/types/src/testMethod.test.d.ts +1 -0
  27. package/dist/types/src/utility/difference.d.ts +2 -0
  28. package/dist/types/src/utility/difference.test.d.ts +1 -0
  29. package/package.json +24 -42
  30. package/index.js +0 -17
  31. package/src/data/TestClass.js +0 -11
  32. package/src/data/coercible.js +0 -85
  33. package/src/data/testData.js +0 -417
  34. package/src/data/testValues.js +0 -241
  35. package/src/multiTest.js +0 -125
  36. package/src/testCheck.js +0 -67
  37. package/src/testEnforce.js +0 -143
  38. package/src/testMethod.js +0 -439
  39. package/src/utility/difference.js +0 -4
  40. package/types/index.d.ts +0 -8
  41. package/types/index.d.ts.map +0 -1
  42. package/types/src/data/TestClass.d.ts +0 -11
  43. package/types/src/data/TestClass.d.ts.map +0 -1
  44. package/types/src/data/coercible.d.ts +0 -7
  45. package/types/src/data/coercible.d.ts.map +0 -1
  46. package/types/src/data/testData.d.ts +0 -289
  47. package/types/src/data/testData.d.ts.map +0 -1
  48. package/types/src/data/testValues.d.ts +0 -26
  49. package/types/src/data/testValues.d.ts.map +0 -1
  50. package/types/src/multiTest.d.ts +0 -14
  51. package/types/src/multiTest.d.ts.map +0 -1
  52. package/types/src/testCheck.d.ts +0 -11
  53. package/types/src/testCheck.d.ts.map +0 -1
  54. package/types/src/testEnforce.d.ts +0 -12
  55. package/types/src/testEnforce.d.ts.map +0 -1
  56. package/types/src/testMethod.d.ts +0 -27
  57. package/types/src/testMethod.d.ts.map +0 -1
  58. package/types/src/utility/difference.d.ts +0 -3
  59. package/types/src/utility/difference.d.ts.map +0 -1
@@ -0,0 +1,39 @@
1
+ import { describe, it, assert } from 'hippogriff';
2
+ import multiTest from './multiTest.js';
3
+ export default function (data, check, is) {
4
+ it('should exist in the exported "is" object', () => {
5
+ assert.equal(check, is[data.name]);
6
+ });
7
+ multiTest({
8
+ values: data.true,
9
+ test: (value) => check(value),
10
+ assertion: 'true'
11
+ });
12
+ multiTest({
13
+ values: data.false,
14
+ test: (value) => check(value),
15
+ assertion: 'false'
16
+ });
17
+ multiTest({
18
+ values: data.coerceTrue,
19
+ test: (value) => check(value),
20
+ assertion: 'false'
21
+ });
22
+ describe('coerce', () => {
23
+ multiTest({
24
+ values: data.true,
25
+ test: (value) => check(value, true),
26
+ assertion: 'true'
27
+ });
28
+ multiTest({
29
+ values: data.coerceTrue,
30
+ test: (value) => check(value, true),
31
+ assertion: 'true'
32
+ });
33
+ multiTest({
34
+ values: data.coerceFalse,
35
+ test: (value) => check(value, true),
36
+ assertion: 'false'
37
+ });
38
+ });
39
+ }
@@ -0,0 +1,121 @@
1
+ import displayValue from 'display-value';
2
+ import { describe, it, assert } from 'hippogriff';
3
+ import TestClass from './data/TestClass.js';
4
+ import { testTypes } from './data/testData.js';
5
+ import multiTest from './multiTest.js';
6
+ export default function (data, enforcer, enforce, coercer) {
7
+ it('should exist in the exported "enforce" object', () => {
8
+ assert.equal(enforcer, enforce[data.name]);
9
+ });
10
+ it(`should return the setter value when a ${data.name} is provided`, () => {
11
+ let result = null;
12
+ const value1 = data.true[0];
13
+ const value2 = data.true[1];
14
+ if (data.extraArg) {
15
+ result = enforce[data.name](value1, data.extraArg, value2);
16
+ }
17
+ else {
18
+ result = enforce[data.name](value1, value2);
19
+ }
20
+ assert.is(result, value1);
21
+ assert.notIs(result, value2);
22
+ });
23
+ if (coercer === Number) {
24
+ it('should return the min value when a integer less than the min value is provided', () => {
25
+ assert.equal(enforce[data.name](-12, 11, false, 0, 5), 0);
26
+ });
27
+ it('should return the max value when a integer greater than the max value is provided', () => {
28
+ assert.equal(enforce[data.name](12, 11, false, 0, 5), 5);
29
+ });
30
+ }
31
+ multiTest({
32
+ values: data.coerceTrue.map((item) => {
33
+ return {
34
+ input: item,
35
+ output: item
36
+ };
37
+ }),
38
+ message(input) {
39
+ return `should NOT return a coerced ${displayValue(input)} when coerce is false`;
40
+ },
41
+ test: (value) => {
42
+ return enforce[data.name](value, value, false);
43
+ },
44
+ inputKey: 'input',
45
+ outputKey: 'output',
46
+ assertion: 'equal'
47
+ });
48
+ describe('coerce', () => {
49
+ if (coercer) {
50
+ multiTest({
51
+ values: data.coerceTrue.map((item) => {
52
+ return {
53
+ input: item,
54
+ output: coercer(item)
55
+ };
56
+ }),
57
+ message(input) {
58
+ return `should return a coerced ${displayValue(input)} when coerce is true`;
59
+ },
60
+ test(value) {
61
+ return enforce[data.name](value, value, true);
62
+ },
63
+ inputKey: 'input',
64
+ outputKey: 'output',
65
+ assertion: 'equal'
66
+ });
67
+ }
68
+ multiTest({
69
+ values: data.coerceFalse,
70
+ message(input) {
71
+ return `should return the alt value when ${displayValue(input)} is provided and coerce is true`;
72
+ },
73
+ test(value) {
74
+ return enforce[data.name](value, 'testAlt', true);
75
+ },
76
+ output: 'testAlt',
77
+ assertion: 'equal'
78
+ });
79
+ });
80
+ testTypes.forEach((typesData) => {
81
+ if (typesData.name &&
82
+ !([typesData.name].concat(typesData.skip).includes(data.name))) {
83
+ typesData.true.forEach((testItem) => {
84
+ it(`should return the default value when ${displayValue(testItem)} is provided`, () => {
85
+ if (data.extraArg) {
86
+ assert.equal(enforce[data.name](testItem, data.extraArg, data.true[0]), data.true[0]);
87
+ }
88
+ else {
89
+ assert.equal(enforce[data.name](testItem, data.true[0]), data.true[0]);
90
+ }
91
+ });
92
+ });
93
+ }
94
+ });
95
+ if (data.name !== 'instanceOf') {
96
+ it('should return the default value when an instance is provided', () => {
97
+ if (data.extraArg) {
98
+ assert.equal(enforce[data.name](new TestClass(), data.extraArg, data.true[0]), data.true[0]);
99
+ }
100
+ else {
101
+ assert.equal(enforce[data.name](new TestClass(), data.true[0]), data.true[0]);
102
+ }
103
+ });
104
+ }
105
+ it('should return the default value when undefined is provided', () => {
106
+ if (data.extraArg) {
107
+ assert.equal(enforce[data.name](undefined, data.extraArg, data.true[0]), data.true[0]);
108
+ }
109
+ else {
110
+ assert.equal(enforce[data.name](undefined, data.true[0]), data.true[0]);
111
+ }
112
+ });
113
+ it('should return the default value when null is provided', () => {
114
+ if (data.extraArg) {
115
+ assert.equal(enforce[data.name](null, data.extraArg, data.true[0]), data.true[0]);
116
+ }
117
+ else {
118
+ assert.equal(enforce[data.name](null, data.true[0]), data.true[0]);
119
+ }
120
+ });
121
+ }
@@ -0,0 +1,337 @@
1
+ import displayValue from 'display-value';
2
+ import { beforeEach, describe, it, assert } from 'hippogriff';
3
+ import { powerset } from 'object-agent';
4
+ const startCase = (string) => string.split(' ')
5
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
6
+ .join(' ');
7
+ const TEST_METHOD = 'testMethod';
8
+ const everyMethodVariant = powerset(['get', 'other', 'before', 'set'])
9
+ .map((combination) => {
10
+ return {
11
+ name: TEST_METHOD + combination.map(startCase).join(''),
12
+ options: combination
13
+ };
14
+ });
15
+ const processOutput = (value, options = {}) => {
16
+ return (options.stringify && value && value.toString) ? value.toString() : value;
17
+ };
18
+ const beforeSymbol = Symbol();
19
+ const setSymbol = Symbol();
20
+ const getSymbol = Symbol();
21
+ export default function (settings, thisMethod, method) {
22
+ let testBefore = '';
23
+ let testSet = '';
24
+ let self = this;
25
+ const testBeforeCallback = function (oldValue) {
26
+ self = this;
27
+ testBefore = processOutput(oldValue, settings.extraProps);
28
+ };
29
+ const testSetCallback = function (newValue) {
30
+ self = this;
31
+ testSet = processOutput(newValue, settings.extraProps);
32
+ };
33
+ const testGetCallback = function () {
34
+ self = this;
35
+ return settings.init;
36
+ };
37
+ const testGetCallbackWithTestItem = function () {
38
+ self = this;
39
+ return settings.true[0];
40
+ };
41
+ beforeEach(() => {
42
+ testBefore = null;
43
+ testSet = null;
44
+ self = null;
45
+ });
46
+ const runTests = (TestConstructor, init, testItem, coerce) => {
47
+ everyMethodVariant.forEach((methodData) => {
48
+ const methodName = methodData.name;
49
+ const hasGet = methodData.options.includes('get');
50
+ const hasOther = methodData.options.includes('other');
51
+ const hasBefore = methodData.options.includes('before');
52
+ const hasSet = methodData.options.includes('set');
53
+ describe('(' + methodName.replace('testMethod', '') + ')', () => {
54
+ it('should return the init value', () => {
55
+ const testConstructor = new TestConstructor();
56
+ assert.equal(testConstructor[methodName](), init);
57
+ });
58
+ it('should return "this" after a value is set', () => {
59
+ const testConstructor = new TestConstructor();
60
+ const that = testConstructor[methodName](testItem);
61
+ assert.is(that, testConstructor);
62
+ });
63
+ if (hasGet) {
64
+ it('should return whatever the "get" callback returns', () => {
65
+ const testConstructor = new TestConstructor();
66
+ testConstructor[methodName](testItem);
67
+ assert.equal(testConstructor[methodName](), init);
68
+ assert.is(testConstructor, self);
69
+ });
70
+ }
71
+ else {
72
+ it('should return a set value', () => {
73
+ const testConstructor = new TestConstructor();
74
+ testConstructor[methodName](testItem);
75
+ assert.equal(testConstructor[methodName](), testItem);
76
+ });
77
+ }
78
+ if (hasSet) {
79
+ it('should execute the "set" callback when the value is set', () => {
80
+ const testConstructor = new TestConstructor();
81
+ testSet = '';
82
+ testConstructor[methodName](testItem);
83
+ assert.equal(testSet, testItem);
84
+ assert.is(testConstructor, self);
85
+ });
86
+ it('should execute the "set" callback when the value is set to the current value and a second parameter of "true" is provided', () => {
87
+ const testConstructor = new TestConstructor();
88
+ testSet = '';
89
+ testConstructor[methodName](testItem);
90
+ testSet = '';
91
+ testConstructor[methodName](testItem, true);
92
+ assert.equal(testSet, testItem);
93
+ });
94
+ if (!hasGet) {
95
+ it('should NOT execute the "set" callback when the value is set to the current value', () => {
96
+ const testConstructor = new TestConstructor();
97
+ testSet = '';
98
+ testConstructor[methodName](testItem);
99
+ testSet = '';
100
+ testConstructor[methodName](testItem);
101
+ assert.equal(testSet, '');
102
+ });
103
+ }
104
+ }
105
+ if (hasBefore) {
106
+ it('should call the "before" callback with the init value when a value is set', () => {
107
+ const testConstructor = new TestConstructor();
108
+ testBefore = '';
109
+ testConstructor[methodName](testItem);
110
+ assert.equal(testBefore, init);
111
+ assert.is(testConstructor, self);
112
+ });
113
+ }
114
+ if (hasOther) {
115
+ it('should be able to be set to other', () => {
116
+ const testConstructor = new TestConstructor();
117
+ if (!hasBefore && !hasGet) {
118
+ testConstructor[methodName](undefined);
119
+ assert.equal(testConstructor[methodName](), undefined);
120
+ }
121
+ else if (hasSet && init) {
122
+ testSet = '';
123
+ testConstructor[methodName](undefined);
124
+ assert.equal(testSet, undefined);
125
+ }
126
+ else if (hasBefore && !hasGet && init) {
127
+ testBefore = '';
128
+ testConstructor[methodName](undefined);
129
+ testConstructor[methodName](testItem);
130
+ assert.equal(testBefore, undefined);
131
+ }
132
+ else if (hasBefore && hasGet && init) {
133
+ testBefore = '';
134
+ testConstructor[methodName](undefined);
135
+ assert.equal(testBefore, init);
136
+ }
137
+ });
138
+ }
139
+ coerce.forEach((item) => {
140
+ if (!hasGet) {
141
+ it('should coerce ' + displayValue(item.value) + ' to ' + displayValue(item.coerced), () => {
142
+ const testConstructor = new TestConstructor();
143
+ testConstructor[methodName](item.value);
144
+ assert.equal(testConstructor[methodName](), item.coerced);
145
+ });
146
+ }
147
+ else if (hasSet) {
148
+ it('should coerce ' + displayValue(item.value) + ' to ' + displayValue(item.coerced), () => {
149
+ const testConstructor = new TestConstructor();
150
+ testSet = '';
151
+ testConstructor[methodName](item.value);
152
+ assert.equal(testSet, item.coerced);
153
+ });
154
+ }
155
+ });
156
+ });
157
+ });
158
+ it('should not set the value of another method with the same variant', () => {
159
+ const testConstructor = new TestConstructor();
160
+ testConstructor[TEST_METHOD](testItem);
161
+ assert.equal(testConstructor[TEST_METHOD](), testItem);
162
+ assert.equal(testConstructor[TEST_METHOD + '2'](), init);
163
+ });
164
+ };
165
+ const getOptionCallback = (option, withTestItem, isReassigned, isSymbol) => {
166
+ if (isSymbol) {
167
+ switch (option) {
168
+ case 'get':
169
+ return withTestItem ? testGetCallbackWithTestItem : getSymbol;
170
+ case 'other':
171
+ return undefined;
172
+ case 'before':
173
+ return beforeSymbol;
174
+ case 'set':
175
+ return setSymbol;
176
+ }
177
+ }
178
+ if (isReassigned) {
179
+ switch (option) {
180
+ case 'get':
181
+ return withTestItem ? testGetCallbackWithTestItem : 'testGetCallback';
182
+ case 'other':
183
+ return undefined;
184
+ case 'before':
185
+ return 'testBeforeCallback';
186
+ case 'set':
187
+ return 'testSetCallback';
188
+ }
189
+ }
190
+ switch (option) {
191
+ case 'get':
192
+ return withTestItem ? testGetCallbackWithTestItem : testGetCallback;
193
+ case 'other':
194
+ return undefined;
195
+ case 'before':
196
+ return testBeforeCallback;
197
+ case 'set':
198
+ return testSetCallback;
199
+ }
200
+ };
201
+ const addMethodsTo = (applyTo, extraProperties = {}, isReassigned = false, isSymbol = false) => {
202
+ everyMethodVariant.forEach((methodData) => {
203
+ const options = {
204
+ ...settings.extraProps,
205
+ ...extraProperties
206
+ };
207
+ methodData.options.forEach((option) => {
208
+ options[option] = getOptionCallback(option, extraProperties.init, isReassigned, isSymbol);
209
+ });
210
+ applyTo[methodData.name] = method[settings.name](options);
211
+ });
212
+ applyTo[TEST_METHOD + '2'] = method[settings.name]({
213
+ ...settings.extraProps,
214
+ ...extraProperties
215
+ });
216
+ };
217
+ it('should exist in the exported "method" object', () => {
218
+ assert.equal(thisMethod, method[settings.name]);
219
+ });
220
+ describe('(prototype)', () => {
221
+ class TestConstructor1 {
222
+ }
223
+ addMethodsTo(TestConstructor1.prototype);
224
+ runTests(TestConstructor1, settings.init, settings.true[0], settings.coerce || []);
225
+ });
226
+ describe('(prototype) (reassigned methods string property)', () => {
227
+ class TestConstructor1 {
228
+ testBeforeCallback;
229
+ testSetCallback;
230
+ testGetCallback;
231
+ constructor() {
232
+ this.testBeforeCallback = testBeforeCallback;
233
+ this.testSetCallback = testSetCallback;
234
+ this.testGetCallback = testGetCallback;
235
+ }
236
+ }
237
+ addMethodsTo(TestConstructor1.prototype, {}, true);
238
+ runTests(TestConstructor1, settings.init, settings.true[0], settings.coerce || []);
239
+ });
240
+ describe('(prototype) (reassigned methods symbol property)', () => {
241
+ class TestConstructor1 {
242
+ [beforeSymbol];
243
+ [setSymbol];
244
+ [getSymbol];
245
+ constructor() {
246
+ this[beforeSymbol] = testBeforeCallback;
247
+ this[setSymbol] = testSetCallback;
248
+ this[getSymbol] = testGetCallback;
249
+ }
250
+ }
251
+ addMethodsTo(TestConstructor1.prototype, {}, true, true);
252
+ runTests(TestConstructor1, settings.init, settings.true[0], settings.coerce || []);
253
+ });
254
+ describe('(prototype) (reassigned method string proto)', () => {
255
+ class TestConstructor1 {
256
+ }
257
+ Object.assign(TestConstructor1.prototype, {
258
+ testBeforeCallback,
259
+ testSetCallback,
260
+ testGetCallback
261
+ });
262
+ addMethodsTo(TestConstructor1.prototype, {}, true);
263
+ runTests(TestConstructor1, settings.init, settings.true[0], settings.coerce || []);
264
+ });
265
+ describe('(prototype) (reassigned method symbol proto)', () => {
266
+ class TestConstructor1 {
267
+ }
268
+ Object.assign(TestConstructor1.prototype, {
269
+ [beforeSymbol]: testBeforeCallback,
270
+ [setSymbol]: testSetCallback,
271
+ [getSymbol]: testGetCallback
272
+ });
273
+ addMethodsTo(TestConstructor1.prototype, {}, true, true);
274
+ runTests(TestConstructor1, settings.init, settings.true[0], settings.coerce || []);
275
+ });
276
+ describe('(prototype) (init)', () => {
277
+ class TestConstructor2 {
278
+ }
279
+ addMethodsTo(TestConstructor2.prototype, {
280
+ init: settings.true[0]
281
+ });
282
+ runTests(TestConstructor2, settings.true[0], settings.true[1], settings.coerce || []);
283
+ settings.false.forEach((falseValue) => {
284
+ it(`should return ${displayValue(settings.true[0])} after attempting to set to ${displayValue(falseValue)}`, () => {
285
+ const testConstructor = new TestConstructor2();
286
+ testConstructor.testMethod(falseValue);
287
+ assert.equal(testConstructor.testMethod(), settings.true[0]);
288
+ });
289
+ });
290
+ });
291
+ describe('(property)', () => {
292
+ const TestConstructor3 = function () {
293
+ addMethodsTo(this);
294
+ };
295
+ runTests(TestConstructor3, settings.init, settings.true[0], settings.coerce || []);
296
+ });
297
+ describe('(property) (init)', () => {
298
+ const TestConstructor4 = function () {
299
+ addMethodsTo(this, {
300
+ init: settings.true[0]
301
+ });
302
+ };
303
+ runTests(TestConstructor4, settings.true[0], settings.true[1], settings.coerce || []);
304
+ });
305
+ if (settings.coerce !== false) {
306
+ describe('(prototype) (coerce=true)', () => {
307
+ class TestConstructor2 {
308
+ }
309
+ addMethodsTo(TestConstructor2.prototype, {
310
+ init: undefined,
311
+ coerce: true
312
+ });
313
+ settings.coerceTrue?.forEach((value) => {
314
+ it(`should return coerced ${displayValue(value)} after attempting to set to ${displayValue(value)}`, () => {
315
+ const testConstructor = new TestConstructor2();
316
+ testConstructor.testMethod(value);
317
+ assert.notIs(testConstructor.testMethod(), undefined);
318
+ });
319
+ });
320
+ });
321
+ describe('(prototype) (coerce=false)', () => {
322
+ class TestConstructor2 {
323
+ }
324
+ addMethodsTo(TestConstructor2.prototype, {
325
+ init: undefined,
326
+ coerce: false
327
+ });
328
+ settings.coerceTrue?.forEach((value) => {
329
+ it(`should return coerced ${displayValue(value)} after attempting to set to ${displayValue(value)}`, () => {
330
+ const testConstructor = new TestConstructor2();
331
+ testConstructor.testMethod(value);
332
+ assert.is(testConstructor.testMethod(), undefined);
333
+ });
334
+ });
335
+ });
336
+ }
337
+ }
@@ -0,0 +1,7 @@
1
+ export default (array1, ...args) => {
2
+ const diffArrays = [];
3
+ args.forEach((arg) => {
4
+ diffArrays.push(...arg);
5
+ });
6
+ return array1.filter((item) => !diffArrays.includes(item));
7
+ };
@@ -0,0 +1,7 @@
1
+ export * from './src/data/testValues.js';
2
+ export { default as TestClass } from './src/data/TestClass.js';
3
+ export * from './src/data/testData.js';
4
+ export { default as multiTest } from './src/multiTest.js';
5
+ export { default as testCheck } from './src/testCheck.js';
6
+ export { default as testEnforce } from './src/testEnforce.js';
7
+ export { default as testMethod } from './src/testMethod.js';
@@ -0,0 +1,6 @@
1
+ export default class TestClass {
2
+ private _value;
3
+ constructor(value?: unknown);
4
+ get value(): unknown;
5
+ set value(value: unknown);
6
+ }
@@ -0,0 +1,6 @@
1
+ export declare const coerceArrayTrue: Array<unknown>;
2
+ export declare const coerceInfinity: Array<unknown>;
3
+ export declare const coerceIntegerTrue: Array<unknown>;
4
+ export declare const coerceFloatTrue: Array<unknown>;
5
+ export declare const coerceNumberFalse: Array<unknown>;
6
+ export declare const coerceObjectTrue: Array<unknown>;
@@ -0,0 +1,30 @@
1
+ import { type is as Is } from 'type-enforcer';
2
+ export interface TestData<T> {
3
+ value?: unknown;
4
+ skip?: Array<keyof typeof Is>;
5
+ name: keyof typeof Is;
6
+ true: Array<T>;
7
+ false: Array<unknown>;
8
+ coerceTrue: Array<unknown>;
9
+ coerceFalse: Array<unknown>;
10
+ extraArg?: T;
11
+ }
12
+ export declare const arrayData: TestData<Array<unknown>>;
13
+ export declare const booleanData: TestData<boolean>;
14
+ export declare const dateData: TestData<Date>;
15
+ export declare const functionData: TestData<Function>;
16
+ export declare const instanceData: TestData<unknown>;
17
+ export declare const integerData: TestData<number>;
18
+ export declare const jsonData: TestData<unknown>;
19
+ export declare const floatData: TestData<number>;
20
+ export declare const numberData: TestData<number>;
21
+ export declare const mapData: TestData<Map<unknown, unknown>>;
22
+ export declare const objectData: TestData<Object>;
23
+ export declare const promiseData: TestData<Promise<unknown>>;
24
+ export declare const regExpData: TestData<RegExp>;
25
+ export declare const setData: TestData<Set<unknown>>;
26
+ export declare const stringData: TestData<string>;
27
+ export declare const symbolData: TestData<Symbol>;
28
+ export declare const weakMapData: TestData<WeakMap<WeakRef<WeakKey>, unknown>>;
29
+ export declare const weakSetData: TestData<WeakSet<WeakRef<WeakKey>>>;
30
+ export declare const testTypes: Array<TestData<unknown>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ export declare const validArrays: Array<Array<unknown>>;
2
+ export declare const validBooleans: Array<boolean>;
3
+ export declare const validDates: Array<Date>;
4
+ export declare const validFunctions: Array<Function>;
5
+ export declare const validInstances: Array<unknown>;
6
+ export declare const validIntegers: Array<number>;
7
+ export declare const validFloats: Array<number>;
8
+ export declare const validInfinities: Array<number>;
9
+ export declare const validMaps: Array<Map<unknown, unknown>>;
10
+ export declare const validObjects: Array<Object>;
11
+ export declare const validPromises: Array<Promise<unknown>>;
12
+ export declare const validRegExps: Array<RegExp>;
13
+ export declare const validSets: Array<Set<unknown>>;
14
+ export declare const validStrings: Array<string>;
15
+ export declare const validSymbols: Array<Symbol>;
16
+ export declare const validWeakMaps: Array<WeakMap<WeakRef<WeakKey>, unknown>>;
17
+ export declare const validWeakSets: Array<WeakSet<WeakRef<WeakKey>>>;
18
+ export declare const validNots: Array<undefined | null | typeof NaN>;
19
+ export declare const testValues: Array<unknown>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,58 @@
1
+ import { assert } from 'hippogriff';
2
+ interface IMultiTestValuesObject<Type> {
3
+ [key: string]: Type;
4
+ }
5
+ interface IMultiTestSettingsObject<Type> {
6
+ values: IMultiTestValuesObject<Type>;
7
+ test: (value: Type) => unknown;
8
+ filter?: (value: unknown) => boolean;
9
+ message?: (input: unknown, output: unknown) => string;
10
+ output?: unknown;
11
+ assertion?: keyof typeof assert | 'true' | 'false';
12
+ }
13
+ interface IMultiTestSettingsPairs<Type> {
14
+ values: Array<Type>;
15
+ values2: Array<Type>;
16
+ test: (value1: Type, value2: Type) => unknown;
17
+ filter?: (value: Type, value2: Type) => boolean;
18
+ message?: (input: unknown, output: unknown) => string;
19
+ output?: unknown;
20
+ assertion?: keyof typeof assert | 'true' | 'false';
21
+ eachPair: true;
22
+ }
23
+ interface IMultiTestSettingsPairsCollection<Type, Values = {
24
+ [key: string]: Type;
25
+ }> {
26
+ values: Array<Values>;
27
+ values2: Array<Values>;
28
+ test: (value1: Type, value2: Type) => unknown;
29
+ filter?: (value: Values, value2: Values) => boolean;
30
+ message?: (input: unknown, output: unknown) => string;
31
+ inputKey: keyof Values;
32
+ output?: unknown;
33
+ assertion?: keyof typeof assert | 'true' | 'false';
34
+ eachPair: true;
35
+ }
36
+ interface IMultiTestSettingsSingle<Type> {
37
+ values: Array<Type>;
38
+ test: (value: Type) => unknown;
39
+ filter?: (value: Type) => boolean;
40
+ message?: (input: unknown, output: unknown) => string;
41
+ output?: unknown;
42
+ assertion?: keyof typeof assert | 'true' | 'false';
43
+ }
44
+ interface IMultiTestSettingsSingleCollection<Type, Values = {
45
+ [key: string]: Type;
46
+ }> {
47
+ values: Array<Values>;
48
+ test: (value: Type) => unknown;
49
+ filter?: (value: Values) => boolean;
50
+ message?: (input: unknown, output: unknown) => string;
51
+ inputKey?: keyof Values;
52
+ outputKey?: keyof Values;
53
+ output?: unknown;
54
+ assertion?: keyof typeof assert | 'true' | 'false';
55
+ }
56
+ type IMultiTestSettings<Type> = IMultiTestSettingsObject<Type> | IMultiTestSettingsPairs<Type> | IMultiTestSettingsPairsCollection<Type> | IMultiTestSettingsSingle<Type> | IMultiTestSettingsSingleCollection<Type>;
57
+ declare const _default: <Type>(settings: IMultiTestSettings<Type>) => void;
58
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type is as Is } from 'type-enforcer';
2
+ import { TestData } from './data/testData.js';
3
+ export default function (data: TestData<unknown>, check: (value: unknown, coerce?: boolean) => boolean, is: typeof Is): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { type TestData } from './data/testData.js';
2
+ export default function <Type>(data: TestData<Type>, enforcer: any, enforce: any, coercer: any): void;
@@ -0,0 +1 @@
1
+ export {};