expect-webdriverio 3.2.1 → 3.3.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.
- package/lib/utils.js +14 -10
- package/package.json +1 -1
package/lib/utils.js
CHANGED
|
@@ -87,7 +87,15 @@ const compareText = (actual, expected, { ignoreCase = false, trim = true, contai
|
|
|
87
87
|
}
|
|
88
88
|
if (ignoreCase) {
|
|
89
89
|
actual = actual.toLowerCase();
|
|
90
|
-
expected
|
|
90
|
+
if (!(expected instanceof RegExp)) {
|
|
91
|
+
expected = expected.toLowerCase();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (expected instanceof RegExp) {
|
|
95
|
+
return {
|
|
96
|
+
value: actual,
|
|
97
|
+
result: !!actual.match(expected)
|
|
98
|
+
};
|
|
91
99
|
}
|
|
92
100
|
if (containing) {
|
|
93
101
|
return {
|
|
@@ -113,18 +121,14 @@ const compareTextWithArray = (actual, expectedArray, { ignoreCase = false, trim
|
|
|
113
121
|
}
|
|
114
122
|
if (ignoreCase) {
|
|
115
123
|
actual = actual.toLowerCase();
|
|
116
|
-
expectedArray = expectedArray.map(item => item.toLowerCase());
|
|
117
|
-
}
|
|
118
|
-
if (containing) {
|
|
119
|
-
const textInArray = expectedArray.some((t) => actual.includes(t));
|
|
120
|
-
return {
|
|
121
|
-
value: actual,
|
|
122
|
-
result: textInArray
|
|
123
|
-
};
|
|
124
|
+
expectedArray = expectedArray.map(item => (item instanceof RegExp) ? item : item.toLowerCase());
|
|
124
125
|
}
|
|
126
|
+
const textInArray = expectedArray.some((expected) => {
|
|
127
|
+
return expected instanceof RegExp ? !!actual.match(expected) : containing ? actual.includes(expected) : actual === expected;
|
|
128
|
+
});
|
|
125
129
|
return {
|
|
126
130
|
value: actual,
|
|
127
|
-
result:
|
|
131
|
+
result: textInArray
|
|
128
132
|
};
|
|
129
133
|
};
|
|
130
134
|
exports.compareTextWithArray = compareTextWithArray;
|