@truenas/ui-components 0.3.19 → 0.3.20
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.
|
@@ -2199,7 +2199,11 @@ class TnBannerHarness extends ComponentHarness {
|
|
|
2199
2199
|
*/
|
|
2200
2200
|
static with(options = {}) {
|
|
2201
2201
|
return new HarnessPredicate(TnBannerHarness, options)
|
|
2202
|
-
.addOption('textContains', options.textContains, (harness, text) => HarnessPredicate.stringMatches(harness.getText(),
|
|
2202
|
+
.addOption('textContains', options.textContains, (harness, text) => HarnessPredicate.stringMatches(harness.getText(),
|
|
2203
|
+
// strings trigger exact matching in `stringMatches`, but since we call the option
|
|
2204
|
+
// `textContains`, this would be misleading. here, we convert strings to a Regex
|
|
2205
|
+
// to trigger partial matching behavior on `stringMatches`.
|
|
2206
|
+
typeof text === 'string' ? new RegExp(helperEscapeRegex(text)) : text));
|
|
2203
2207
|
}
|
|
2204
2208
|
/**
|
|
2205
2209
|
* Gets all text content from the banner (heading + message combined).
|
|
@@ -2218,6 +2222,15 @@ class TnBannerHarness extends ComponentHarness {
|
|
|
2218
2222
|
return (await host.text()).trim();
|
|
2219
2223
|
}
|
|
2220
2224
|
}
|
|
2225
|
+
/**
|
|
2226
|
+
* helper function to stand-in for `RegExp.escape`, since that doesn't
|
|
2227
|
+
* exist in our deployment target of ES2023.
|
|
2228
|
+
* @param text a string to escape.
|
|
2229
|
+
* @returns an escaped string, safe for using in the `RegExp` constructor.
|
|
2230
|
+
*/
|
|
2231
|
+
function helperEscapeRegex(text) {
|
|
2232
|
+
return text.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
2233
|
+
}
|
|
2221
2234
|
|
|
2222
2235
|
const escapableChars = new Set(['*', '`', '\\']);
|
|
2223
2236
|
function isWhitespace(char) {
|