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,20 @@
1
+ interface ITestMethodCoerce {
2
+ value: unknown;
3
+ coerced: unknown;
4
+ }
5
+ interface ExtraProps {
6
+ [key: string]: unknown;
7
+ }
8
+ interface ITestMethodSettings {
9
+ name: string;
10
+ init: unknown;
11
+ extraProps?: ExtraProps;
12
+ true: Array<unknown>;
13
+ false: Array<unknown>;
14
+ coerce?: Array<ITestMethodCoerce> | false;
15
+ coerceTrue?: Array<unknown>;
16
+ }
17
+ export default function (this: object, settings: ITestMethodSettings, thisMethod: Function, method: {
18
+ [key: string]: unknown;
19
+ }): void;
20
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const _default: (array1: Array<unknown>, ...args: Array<Array<unknown>>) => Array<unknown>;
2
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-enforcer-test-helper",
3
- "version": "1.3.10",
3
+ "version": "2.0.0-alpha.0",
4
4
  "description": "Test data and helper functions for type-enforcer and addons",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -17,65 +17,47 @@
17
17
  "bugs": {
18
18
  "url": "https://github.com/DarrenPaulWright/type-enforcer-test-helper/issues"
19
19
  },
20
- "main": "index.js",
21
20
  "type": "module",
22
- "types": "types/index.d.ts",
21
+ "main": "dist/js/index.ts",
22
+ "module": "dist/js/index.ts",
23
+ "types": "dist/types/index.d.ts",
23
24
  "files": [
24
- "/types",
25
- "/src"
25
+ "/dist",
26
+ "!/dist/**/*.test.js",
27
+ "!/dist/**/*.test.d.js"
26
28
  ],
27
- "badges": {
28
- "npm": {
29
- "image": "https://img.shields.io/npm/v/type-enforcer-test-helper.svg",
30
- "url": "https://npmjs.com/package/type-enforcer-test-helper"
31
- },
32
- "deps": {
33
- "image": "https://david-dm.org/DarrenPaulWright/type-enforcer-test-helper.svg",
34
- "url": "https://david-dm.org/DarrenPaulWright/type-enforcer-test-helper"
35
- },
36
- "size": {
37
- "base": "https://packagephobia.now.sh/",
38
- "image": "badge?p=type-enforcer-test-helper",
39
- "url": "result?p=type-enforcer-test-helper"
40
- },
41
- "vulnerabilities": {
42
- "base": "https://snyk.io/test/github/DarrenPaulWright/type-enforcer-test-helper",
43
- "image": "/badge.svg?targetFile=package.json",
44
- "url": "?targetFile=package.json"
45
- },
46
- "license": {
47
- "image": "https://img.shields.io/github/license/DarrenPaulWright/type-enforcer-test-helper.svg",
48
- "url": "https://npmjs.com/package/type-enforcer-test-helper/LICENSE.md"
49
- }
50
- },
51
29
  "scripts": {
52
- "test": "",
30
+ "test": "tsc && hippogriff",
53
31
  "test-watch": "",
54
32
  "preversion": "npm test && npm run docs && git add --all && git diff HEAD --quiet || git commit -m \"Updating docs\"",
55
33
  "postversion": "npm publish",
56
34
  "postpublish": "git push --follow-tags",
57
35
  "pre-clean": "rm -rf node_modules && del /f package-lock.json",
58
- "clean": "npm run pre-clean && npm install && npm audit fix",
59
- "update": "ncu -u && git diff --quiet || npm install && npm audit fix",
36
+ "clean": "npm run pre-clean && npm install",
37
+ "update": "ncu -u && git diff --quiet || npm install",
60
38
  "update-clean": "npm run pre-clean && npm run update",
61
39
  "update-commit": "npm run update && npm test && git add --all && git diff HEAD --quiet || git commit -m \"Updating dependencies\"",
62
40
  "update-patch": "npm run update && npm test && git add --all && git diff HEAD --quiet || git commit -m \"Updating dependencies\" && npm version patch",
63
- "docs:readme": "jsdoc2md ./index.js src/**/*.js > README.md -t node_modules/dmd-readable/overview.hbs --plugin dmd-readable/overview-plugin.js",
64
- "docs:main": "exec-each --out docs/{basefile}.md src/*.js jsdoc2md -- {path} -t node_modules/dmd-readable/docs.hbs --plugin dmd-readable",
65
- "docs:data": "exec-each --out docs/{basefile}.md src/data/*.js jsdoc2md -- {path} -t node_modules/dmd-readable/docs.hbs --plugin dmd-readable",
66
- "docs:types": "rm -rf types && tsc",
67
- "docs": "run-p docs:*"
41
+ "docs": "typedoc"
68
42
  },
69
43
  "dependencies": {
70
- "display-value": "^2.2.0",
71
- "object-agent": "^1.6.0",
72
- "type-enforcer": "^1.2.4"
44
+ "display-value": "^3.1.0",
45
+ "object-agent": "^1.6.1",
46
+ "type-enforcer": "^1.2.7"
47
+ },
48
+ "peerDependencies": {
49
+ "hippogriff": "^0.1.2"
73
50
  },
74
51
  "devDependencies": {
52
+ "@types/node": "^25.0.3",
75
53
  "dmd-readable": "^1.2.4",
76
54
  "exec-each": "0.0.3",
77
- "jsdoc-to-markdown": "^8.0.0",
55
+ "hippogriff": "0.1.2",
56
+ "jsdoc-to-markdown": "^9.1.3",
78
57
  "npm-run-all": "^4.1.5",
79
- "typescript": "^5.2.2"
58
+ "typedoc": "^0.28.15",
59
+ "typedoc-plugin-markdown": "^4.9.0",
60
+ "typedoc-plugin-missing-exports": "^4.1.2",
61
+ "typescript": "^5.9.3"
80
62
  }
81
63
  }
package/index.js DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * @name About
3
- * @private
4
- * @summary
5
- *
6
- * This library consists of two things. First is a data set of variations of different data type instances and values, along with coercible values, many of which were hand picked from the [big-list-of-naughty-strings](https://github.com/minimaxir/big-list-of-naughty-strings). Second is a handful of functions to help in testing type-enforcer and type-enforcer addons.
7
- */
8
-
9
- export * from './src/data/testValues.js';
10
- export { default as TestClass } from './src/data/TestClass.js';
11
- export * from './src/data/testData.js';
12
-
13
- export { default as multiTest } from './src/multiTest.js';
14
-
15
- export { default as testCheck } from './src/testCheck.js';
16
- export { default as testEnforce } from './src/testEnforce.js';
17
- export { default as testMethod } from './src/testMethod.js';
@@ -1,11 +0,0 @@
1
- /**
2
- * @class TestClass
3
- * @classdesc A simple class for testing things like instanceof
4
- *
5
- * @param {unknown} value - Adds a property "value" to an instance of TestClass, set to the value provided.
6
- */
7
- export default class TestClass {
8
- constructor(value) {
9
- this.value = value;
10
- }
11
- }
@@ -1,85 +0,0 @@
1
- export const coerceArrayTrue = ['["test"]', '[]'];
2
-
3
- export const coerceInfinity = [
4
- 'Infinity',
5
- '-Infinity'
6
- ];
7
-
8
- export const coerceIntegerTrue = [
9
- '0',
10
- '1',
11
- '1.00',
12
- '1E2',
13
- '1E02',
14
- '1E+02',
15
- '-1',
16
- '-1.00',
17
- '-1E2',
18
- '-1E02',
19
- '-1E+02',
20
- '-0',
21
- '-0.0',
22
- '+0',
23
- '+0.0',
24
- '0.00',
25
- '0x0',
26
- '0xffffffff',
27
- '0xffffffffffffffff',
28
- '0xabad1dea',
29
- '01000',
30
- '08',
31
- '09'];
32
-
33
- export const coerceFloatTrue = [
34
- '3.2',
35
- '10.5'
36
- ];
37
-
38
- export const coerceNumberFalse = [
39
- '$1.00',
40
- '1/2',
41
- '-$1.00',
42
- '-1/2',
43
- '1/0',
44
- '0/0',
45
- '-2147483648/-1',
46
- '-9223372036854775808/-1',
47
- '0..0',
48
- '.',
49
- '0.0.0',
50
- '0,00',
51
- '0,,0',
52
- ',',
53
- '0,0,0',
54
- '0.0/0',
55
- '1.0/0.0',
56
- '0.0/0.0',
57
- '1,0/0,0',
58
- '0,0/0,0',
59
- '--1',
60
- '-',
61
- '-.',
62
- '-,',
63
- 'NaN',
64
- 'INF',
65
- '1#INF',
66
- '-1#IND',
67
- '1#QNAN',
68
- '1#SNAN',
69
- '1#IND',
70
- '1,000.00',
71
- '1 000.00',
72
- '1\'000.00',
73
- '1,000,000.00',
74
- '1 000 000.00',
75
- '1\'000\'000.00',
76
- '1.000,00',
77
- '1 000,00',
78
- '1\'000,00',
79
- '1.000.000,00',
80
- '1 000 000,00',
81
- '1\'000\'000,00',
82
- NaN
83
- ];
84
-
85
- export const coerceObjectTrue = ['{}', '{"test":"test"}'];
@@ -1,417 +0,0 @@
1
- import difference from '../utility/difference.js';
2
- import {
3
- coerceArrayTrue,
4
- coerceFloatTrue,
5
- coerceInfinity,
6
- coerceIntegerTrue,
7
- coerceNumberFalse,
8
- coerceObjectTrue
9
- } from './coercible.js';
10
- import TestClass from './TestClass.js';
11
- import {
12
- testValues,
13
- validArrays,
14
- validBooleans,
15
- validDates,
16
- validFloats,
17
- validFunctions,
18
- validInfinities,
19
- validInstances,
20
- validIntegers,
21
- validMaps,
22
- validObjects,
23
- validPromises,
24
- validRegExps,
25
- validSets,
26
- validStrings,
27
- validSymbols,
28
- validWeakMaps,
29
- validWeakSets
30
- } from './testValues.js';
31
-
32
- /**
33
- * An array of all the test type objects (arrayData, booleanData, etc.)
34
- *
35
- * @constant {Array} testTypes
36
- */
37
-
38
- /**
39
- * A data set for testing Arrays
40
- *
41
- * @constant {object} arrayData
42
- * @property {Function} value - Array constructor
43
- * @property {string} name - The name used in type-enforcer namespaces for this type
44
- * @property {Array} true - [validArrays](testValues.md#validArrays)
45
- * @property {Array} false - [testValues](testValues.md#testValues) minus validArrays
46
- * @property {Array} coerceTrue - Values that can be coerced to this type
47
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
48
- */
49
- export const arrayData = {
50
- value: Array,
51
- name: 'array',
52
- true: validArrays,
53
- false: difference(testValues, validArrays),
54
- coerceTrue: coerceArrayTrue,
55
- coerceFalse: difference(testValues, validArrays)
56
- };
57
-
58
- /**
59
- * A data set for testing Booleans
60
- *
61
- * @constant {object} booleanData
62
- * @property {Function} value - Boolean constructor
63
- * @property {string} name - The name used in type-enforcer namespaces for this type
64
- * @property {Array} true - [validBooleans](testValues.md#validBooleans)
65
- * @property {Array} false - [testValues](testValues.md#testValues) minus validBooleans
66
- * @property {Array} coerceTrue - Values that can be coerced to this type
67
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
68
- */
69
- export const booleanData = {
70
- value: Boolean,
71
- name: 'boolean',
72
- true: validBooleans,
73
- false: difference(testValues, validBooleans),
74
- coerceTrue: difference(testValues, validBooleans),
75
- coerceFalse: []
76
- };
77
-
78
- /**
79
- * A data set for testing Dates
80
- *
81
- * @constant {object} dateData
82
- * @property {Function} value - Date constructor
83
- * @property {string} name - The name used in type-enforcer namespaces for this type
84
- * @property {Array} true - [validDates](testValues.md#validDates)
85
- * @property {Array} false - [testValues](testValues.md#testValues) minus validDates
86
- * @property {Array} coerceTrue - Values that can be coerced to this type
87
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
88
- */
89
- export const dateData = {
90
- value: Date,
91
- name: 'date',
92
- true: validDates,
93
- false: difference(testValues, validDates),
94
- coerceTrue: ['10/12/1980', 'January 8, 2014'],
95
- coerceFalse: difference(testValues, validDates, validArrays, validFloats, validIntegers, validRegExps)
96
- };
97
-
98
- /**
99
- * A data set for testing Functions
100
- *
101
- * @constant {object} functionData
102
- * @property {Function} value - Function constructor
103
- * @property {string} name - The name used in type-enforcer namespaces for this type
104
- * @property {Array} true - [validFunctions](testValues.md#validFunctions)
105
- * @property {Array} false - [testValues](testValues.md#testValues) minus validFunctions
106
- * @property {Array} coerceTrue - Values that can be coerced to this type
107
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
108
- */
109
- export const functionData = {
110
- value: Function,
111
- name: 'function',
112
- true: validFunctions,
113
- false: difference(testValues, validFunctions),
114
- coerceTrue: [],
115
- coerceFalse: difference(testValues, validFunctions)
116
- };
117
-
118
- /**
119
- * A data set for testing instanceOf
120
- *
121
- * @constant {object} instanceData
122
- * @property {Function} value - [TestClass](TestClass.md)
123
- * @property {string} name - The name used in type-enforcer namespaces for this type
124
- * @property {Array} true - [validInstances](testValues.md#validInstances)
125
- * @property {Array} false - [testValues](testValues.md#testValues) minus validInstances
126
- * @property {Array} coerceTrue - Included for consistency
127
- * @property {Array} coerceFalse - Included for consistency
128
- */
129
- export const instanceData = {
130
- value: TestClass,
131
- name: 'instanceOf',
132
- true: validInstances,
133
- false: difference(testValues, validInstances),
134
- coerceTrue: [],
135
- coerceFalse: []
136
- };
137
-
138
- /**
139
- * A data set for testing integers
140
- *
141
- * @constant {object} integerData
142
- * @property {string} name - The name used in type-enforcer namespaces for this type
143
- * @property {Array} skip - The "name" property of other test objects that will produce false negatives if tested against this objects data
144
- * @property {Array} true - [validIntegers](testValues.md#validIntegers)
145
- * @property {Array} false - [testValues](testValues.md#testValues) minus validIntegers and validInfinities
146
- * @property {Array} coerceTrue - Values that can be coerced to this type.
147
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
148
- */
149
- export const integerData = {
150
- name: 'integer',
151
- skip: ['number', 'float'],
152
- true: validIntegers,
153
- false: difference(testValues, validIntegers, validInfinities),
154
- coerceTrue: coerceIntegerTrue,
155
- coerceFalse: coerceNumberFalse.concat(coerceFloatTrue, coerceInfinity)
156
- };
157
-
158
- /**
159
- * A data set for testing JSON
160
- *
161
- * @constant {object} jsonData
162
- * @property {string} name - The name used in type-enforcer namespaces for this type
163
- * @property {Array} true - Values that don't throw when passed through JSON.parse()
164
- * @property {Array} false - Values that DO throw when passed through JSON.parse()
165
- * @property {Array} coerceTrue - Included for consistency
166
- * @property {Array} coerceFalse - Included for consistency
167
- */
168
- export const jsonData = {
169
- name: 'json',
170
- true: coerceObjectTrue.concat(coerceArrayTrue, JSON.stringify(testValues)),
171
- false: ['json'].concat(validDates, validFunctions, validObjects, validRegExps),
172
- coerceTrue: [],
173
- coerceFalse: []
174
- };
175
-
176
- /**
177
- * A data set for testing integers
178
- *
179
- * @constant {object} floatData
180
- * @property {string} name - The name used in type-enforcer namespaces for this type
181
- * @property {Array} skip - The "name" property of other test objects that will produce false negatives if tested against this objects data
182
- * @property {Array} true - [validFloats](testValues.md#validFloats)
183
- * @property {Array} false - [testValues](testValues.md#testValues) minus validFloats
184
- * @property {Array} coerceTrue - Values that can be coerced to this type
185
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
186
- */
187
- export const floatData = {
188
- name: 'float',
189
- skip: ['number', 'integer'],
190
- true: validFloats,
191
- false: difference(testValues, validFloats, validIntegers, validInfinities),
192
- coerceTrue: coerceIntegerTrue.concat(coerceFloatTrue),
193
- coerceFalse: coerceNumberFalse.concat(coerceInfinity)
194
- };
195
-
196
- /**
197
- * A data set for testing numbers
198
- *
199
- * @constant {object} numberData
200
- * @property {Function} value - Number constructor
201
- * @property {string} name - The name used in type-enforcer namespaces for this type
202
- * @property {Array} skip - The "name" property of other test objects that will produce false negatives if tested against this objects data
203
- * @property {Array} true - [validFloats](testValues.md#validFloats)
204
- * @property {Array} false - [testValues](testValues.md#testValues) minus validFloats
205
- * @property {Array} coerceTrue - Values that can be coerced to this type
206
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
207
- */
208
- export const numberData = {
209
- value: Number,
210
- name: 'number',
211
- skip: ['integer', 'float'],
212
- true: validFloats.concat(validIntegers, validInfinities),
213
- false: difference(testValues, validFloats, validIntegers, validInfinities, [NaN]),
214
- coerceTrue: coerceIntegerTrue.concat(coerceInfinity),
215
- coerceFalse: coerceNumberFalse
216
- };
217
-
218
- /**
219
- * A data set for testing Maps
220
- *
221
- * @constant {object} mapData
222
- * @property {Function} value - Map constructor
223
- * @property {string} name - The name used in type-enforcer namespaces for this type
224
- * @property {Array} true - [validMaps](testValues.md#validMaps)
225
- * @property {Array} false - [testValues](testValues.md#testValues) minus validMaps
226
- * @property {Array} coerceTrue - Values that can be coerced to this type
227
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
228
- */
229
- export const mapData = {
230
- value: Map,
231
- name: 'map',
232
- true: validMaps,
233
- false: difference(testValues, validMaps),
234
- coerceTrue: coerceObjectTrue.concat(validObjects, [[[TestClass, 2],
235
- [TestClass, 'test']], '[["test 1", 2], ["test 2", "test"]]']),
236
- coerceFalse: difference(testValues, validMaps, validObjects, validArrays).concat(['test'])
237
- };
238
-
239
- /**
240
- * A data set for testing plain Objects
241
- *
242
- * @constant {object} objectData
243
- * @property {Function} value - Object constructor
244
- * @property {string} name - The name used in type-enforcer namespaces for this type
245
- * @property {Array} true - [validObjects](testValues.md#validObjects)
246
- * @property {Array} false - [testValues](testValues.md#testValues) minus validObjects
247
- * @property {Array} coerceTrue - Values that can be coerced to this type
248
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
249
- */
250
- export const objectData = {
251
- value: Object,
252
- name: 'object',
253
- true: validObjects,
254
- false: [null, undefined, true, false],
255
- coerceTrue: coerceObjectTrue,
256
- coerceFalse: validStrings
257
- };
258
-
259
- /**
260
- * A data set for testing Promises
261
- *
262
- * @constant {object} promiseData
263
- * @property {Function} value - Promise constructor
264
- * @property {string} name - The name used in type-enforcer namespaces for this type
265
- * @property {Array} true - [validPromises](testValues.md#validPromises)
266
- * @property {Array} false - [testValues](testValues.md#testValues) minus validPromises
267
- * @property {Array} coerceTrue - [validFunctions](testValues.md#validFunctions)
268
- * @property {Array} coerceFalse - [testValues](testValues.md#testValues) minus validPromises and validFunctions
269
- */
270
- export const promiseData = {
271
- value: Promise,
272
- name: 'promise',
273
- true: validPromises,
274
- false: difference(testValues, validPromises),
275
- coerceTrue: validFunctions,
276
- coerceFalse: difference(testValues, validFunctions, validPromises)
277
- };
278
-
279
- /**
280
- * A data set for testing RegExps
281
- *
282
- * @constant {object} regExpData
283
- * @property {Function} value - RegExp constructor
284
- * @property {string} name - The name used in type-enforcer namespaces for this type
285
- * @property {Array} true - [validRegExps](testValues.md#validRegExps)
286
- * @property {Array} false - [testValues](testValues.md#testValues) minus validRegExps
287
- * @property {Array} coerceTrue - Values that can be coerced to this type
288
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
289
- */
290
- export const regExpData = {
291
- value: RegExp,
292
- name: 'regExp',
293
- true: validRegExps,
294
- false: difference(testValues, validRegExps),
295
- coerceTrue: ['test', '/[a-z]+/', '/[a-z]+/gi'],
296
- coerceFalse: difference(testValues, validStrings, validRegExps)
297
- };
298
-
299
- /**
300
- * A data set for testing Sets
301
- *
302
- * @constant {object} setData
303
- * @property {Function} value - Set constructor
304
- * @property {string} name - The name used in type-enforcer namespaces for this type
305
- * @property {Array} true - [validSets](testValues.md#validSets)
306
- * @property {Array} false - [testValues](testValues.md#testValues) minus validSets
307
- * @property {Array} coerceTrue - Values that can be coerced to this type
308
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
309
- */
310
- export const setData = {
311
- value: Set,
312
- name: 'set',
313
- true: validSets,
314
- false: difference(testValues, validSets),
315
- coerceTrue: validArrays.concat(['[]', '[1, 2]']),
316
- coerceFalse: difference(testValues, validSets, validArrays)
317
- };
318
-
319
- /**
320
- * A data set for testing Strings
321
- *
322
- * @constant {object} stringData
323
- * @property {Function} value - String constructor
324
- * @property {string} name - The name used in type-enforcer namespaces for this type
325
- * @property {Array} true - [validStrings](testValues.md#validStrings)
326
- * @property {Array} false - [testValues](testValues.md#testValues) minus validStrings
327
- * @property {Array} coerceTrue - Values that can be coerced to this type
328
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
329
- */
330
- export const stringData = {
331
- value: String,
332
- name: 'string',
333
- true: validStrings,
334
- false: difference(testValues, validStrings),
335
- coerceTrue: difference(testValues, validStrings, [null, undefined]),
336
- coerceFalse: [null, undefined]
337
- };
338
-
339
- /**
340
- * A data set for testing Symbols
341
- *
342
- * @constant {object} symbolData
343
- * @property {Function} value - Symbol constructor
344
- * @property {string} name - The name used in type-enforcer namespaces for this type
345
- * @property {Array} true - [validSymbols](testValues.md#validSymbols)
346
- * @property {Array} false - [testValues](testValues.md#testValues) minus validSymbols
347
- * @property {Array} coerceTrue - Values that can be coerced to this type
348
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
349
- */
350
- export const symbolData = {
351
- value: Symbol,
352
- name: 'symbol',
353
- true: validSymbols,
354
- false: difference(testValues, validSymbols),
355
- coerceTrue: stringData.coerceTrue,
356
- coerceFalse: stringData.coerceFalse
357
- };
358
-
359
- /**
360
- * A data set for testing WeakMaps
361
- *
362
- * @constant {object} weakMapData
363
- * @property {Function} value - WeakMap constructor
364
- * @property {string} name - The name used in type-enforcer namespaces for this type
365
- * @property {Array} true - [validWeakMaps](testValues.md#validWeakMaps)
366
- * @property {Array} false - [testValues](testValues.md#testValues) minus validWeakMaps
367
- * @property {Array} coerceTrue - Values that can be coerced to this type
368
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
369
- */
370
- export const weakMapData = {
371
- value: WeakMap,
372
- name: 'weakMap',
373
- true: validWeakMaps,
374
- false: difference(testValues, validWeakMaps),
375
- coerceTrue: [[[TestClass, 2], [TestClass, 'test']]],
376
- coerceFalse: difference(testValues, validWeakMaps, validArrays).concat(['test'])
377
- };
378
-
379
- /**
380
- * A data set for testing WeakSets
381
- *
382
- * @constant {object} weakSetData
383
- * @property {Function} value - WeakSet constructor
384
- * @property {string} name - The name used in type-enforcer namespaces for this type
385
- * @property {Array} true - [validWeakSets](testValues.md#validWeakSets)
386
- * @property {Array} false - [testValues](testValues.md#testValues) minus validWeakSets
387
- * @property {Array} coerceTrue - Values that can be coerced to this type
388
- * @property {Array} coerceFalse - Values that cannot be coerced to this type
389
- */
390
- export const weakSetData = {
391
- value: WeakSet,
392
- name: 'weakSet',
393
- true: validWeakSets,
394
- false: difference(testValues, validWeakSets),
395
- coerceTrue: [validInstances],
396
- coerceFalse: difference(testValues, validWeakSets, validArrays)
397
- };
398
-
399
- export const testTypes = [
400
- arrayData,
401
- booleanData,
402
- dateData,
403
- functionData,
404
- instanceData,
405
- integerData,
406
- floatData,
407
- numberData,
408
- mapData,
409
- objectData,
410
- promiseData,
411
- regExpData,
412
- setData,
413
- stringData,
414
- symbolData,
415
- weakMapData,
416
- weakSetData
417
- ];