1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.getValues = getValues;
|
7 | exports.multipleValidOptions = multipleValidOptions;
|
8 | exports.validationCondition = validationCondition;
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | const toString = Object.prototype.toString;
|
17 | const MULTIPLE_VALID_OPTIONS_SYMBOL = Symbol('JEST_MULTIPLE_VALID_OPTIONS');
|
18 | function validationConditionSingle(option, validOption) {
|
19 | return (
|
20 | option === null ||
|
21 | option === undefined ||
|
22 | (typeof option === 'function' && typeof validOption === 'function') ||
|
23 | toString.call(option) === toString.call(validOption)
|
24 | );
|
25 | }
|
26 | function getValues(validOption) {
|
27 | if (
|
28 | Array.isArray(validOption) &&
|
29 |
|
30 | validOption[MULTIPLE_VALID_OPTIONS_SYMBOL]
|
31 | ) {
|
32 | return validOption;
|
33 | }
|
34 | return [validOption];
|
35 | }
|
36 | function validationCondition(option, validOption) {
|
37 | return getValues(validOption).some(e => validationConditionSingle(option, e));
|
38 | }
|
39 | function multipleValidOptions(...args) {
|
40 | const options = [...args];
|
41 |
|
42 | options[MULTIPLE_VALID_OPTIONS_SYMBOL] = true;
|
43 | return options;
|
44 | }
|