Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 67a585b

Browse files
chore(tests): fix behavior test regex (#734)
* chore(tests): fix behavior test regex * - address PR comments
1 parent 7ea813c commit 67a585b

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

test/specs/behaviors/testDefinitions.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const testHelper = new TestHelper()
77

88
// Example: Adds attribute 'aria-pressed=true' based on the property 'active'
99
definitions.push({
10-
regexp: /Adds attribute '([\w\-\w \s*]+)=([a-z]+)' based on the property '([a-z]+)'\./g,
10+
regexp: /Adds attribute '([\w-]+)=(\w+)' based on the property '(\w+)'\./g,
1111
testMethod: (parameters: TestMethod) => {
1212
const [attributeToBeAdded, attributeExpectedValue, propertyDependingOn] = [...parameters.props]
1313
const property = {}
@@ -22,7 +22,7 @@ definitions.push({
2222

2323
// Example: Adds attribute 'aria-hidden=true' to icon
2424
definitions.push({
25-
regexp: /Adds attribute '([\w\-\w \s*]+)=([a-z]+)' to [a-z]+/g,
25+
regexp: /Adds attribute '([\w-]+)=(\w+)' to \w+/g,
2626
testMethod: (parameters: TestMethod) => {
2727
const [attributeToBeAdded, attributeExpectedValue] = [...parameters.props]
2828
const property = {}
@@ -33,7 +33,7 @@ definitions.push({
3333

3434
// Example: Adds role='listbox'.
3535
definitions.push({
36-
regexp: /Adds role='([a-z]+)'\./g,
36+
regexp: /Adds role='(\w+)'\./g,
3737
testMethod: (parameters: TestMethod) => {
3838
const [roleToBeAdded] = [...parameters.props]
3939
const property = {}
@@ -44,7 +44,7 @@ definitions.push({
4444

4545
// Example: Adds role 'menuitem' to 'anchor' component's part
4646
definitions.push({
47-
regexp: /Adds role '([a-z]+)' to '([a-z]+)' component's part/g,
47+
regexp: /Adds role '(\w+)' to '([\w-]+)' component's part/g,
4848
testMethod: (parameters: TestMethod) => {
4949
const [roleToBeAdded, elementWhereToBeAdded] = [...parameters.props]
5050
const property = {}
@@ -56,7 +56,7 @@ definitions.push({
5656
// Example: Adds attribute 'tabIndex=0' to 'anchor' component's part.
5757
// Adds attribute 'data-is-focusable=true' to 'anchor' component's part.
5858
definitions.push({
59-
regexp: /Adds attribute '([a-z A-Z -]+)=([a-z 0-9]+)' to '([a-z]+)' component's part\./g,
59+
regexp: /Adds attribute '([\w-]+)=([\w\d]+)' to '([\w-]+)' component's part\./g,
6060
testMethod: (parameters: TestMethod) => {
6161
const [attributeToBeAdded, attributeExpectedValue, elementWhereToBeAdded] = [
6262
...parameters.props,
@@ -73,7 +73,7 @@ definitions.push({
7373

7474
// Example: Adds attribute 'aria-expanded=true' based on the property 'menuOpen' if the component has 'menu' property to 'anchor' component's part.
7575
definitions.push({
76-
regexp: /Adds attribute '([a-z A-Z -]+)=([a-z 0-9]+)' based on the property '([a-z A-Z -]+)' if the component has '([a-z -]+)' property to '([a-z -]+)' component's part\./g,
76+
regexp: /Adds attribute '([\w-]+)=([\w\d]+)' based on the property '([\w-]+)' if the component has '([\w-]+)' property to '([\w-]+)' component's part\./g,
7777
testMethod: (parameters: TestMethod) => {
7878
const [
7979
attributeToBeAdded,
@@ -110,7 +110,7 @@ definitions.push({
110110

111111
// Example: Adds attribute 'aria-label' based on the property 'aria-label' to 'anchor' component's part.
112112
definitions.push({
113-
regexp: /Adds attribute '([a-z -]+)' based on the property '([a-z -]+)' to '([a-z -]+)' component's part\./g,
113+
regexp: /Adds attribute '([\w-]+)' based on the property '([\w-]+)' to '([\w-]+)' component's part\./g,
114114
testMethod: (parameters: TestMethod) => {
115115
const [attributeToBeAdded, propertyDependingOn, elementWhereToBeAdded] = [...parameters.props]
116116
const property = {}
@@ -127,7 +127,7 @@ definitions.push({
127127

128128
// Adds attribute 'aria-selected=true' to 'anchor' component's part based on the property 'active'. This can be overriden by directly providing 'aria-selected' property to the component.
129129
definitions.push({
130-
regexp: /Adds attribute '([a-zA-Z-]+)=([a-z0-9]+)' to '([a-z-]+)' component's part based on the property '[a-z]+'\. This can be overriden by providing '([a-z-]+)' property directly to the component\./g,
130+
regexp: /Adds attribute '([\w-]+)=([\w\d]+)' to '([\w-]+)' component's part based on the property '\w+'\. This can be overriden by providing '([\w-]+)' property directly to the component\./g,
131131
testMethod: (parameters: TestMethod) => {
132132
const [attributeToBeAdded, valueOfAttributeToBeAdded, component, overridingProperty] = [
133133
...parameters.props,
@@ -146,7 +146,7 @@ definitions.push({
146146

147147
// Example: Adds attribute 'aria-disabled=true' based on the property 'disabled'. This can be overriden by providing 'aria-disabled' property directly to the component.
148148
definitions.push({
149-
regexp: /Adds attribute '([a-z A-Z -]+)=([a-z 0-9]+)' based on the property '[a-z]+'\. This can be overriden by providing '([a-z -]+)' property directly to the component\./g,
149+
regexp: /Adds attribute '([\w-]+)=([\w\d]+)' based on the property '\w+'\. This can be overriden by providing '([\w-]+)' property directly to the component\./g,
150150
testMethod: (parameters: TestMethod) => {
151151
const [attributeToBeAdded, valueOfAttributeToBeAdded, overridingProperty] = [
152152
...parameters.props,
@@ -188,7 +188,7 @@ function testMethodConditionallyAddAttribute(
188188

189189
// Example: Adds attribute 'aria-disabled=true' to 'trigger' component's part if 'disabled' property is true. Does not set the attribute otherwise.
190190
definitions.push({
191-
regexp: /Adds attribute '([a-zA-Z-]+)=([a-z0-9]+)' to '([a-z-]+)' component's part if '([a-z -]+)' property is true\. Does not set the attribute otherwise\./g,
191+
regexp: /Adds attribute '([\w-]+)=([\w\d]+)' to '([\w-]+)' component's part if '([\w-]+)' property is true\. Does not set the attribute otherwise\./g,
192192
testMethod: (parameters: TestMethod) => {
193193
const [attributeToBeAdded, valueOfAttributeToBeAdded, component, propertyDependsOn] = [
194194
...parameters.props,
@@ -208,7 +208,7 @@ definitions.push({
208208

209209
// Example: Adds attribute 'aria-disabled=true' to 'trigger' component's part if 'disabled' property is true. Sets the attribute to 'false' otherwise.
210210
definitions.push({
211-
regexp: /Adds attribute '([a-zA-Z-]+)=([a-z0-9]+)' to '([a-z-]+)' component's part if '([a-z -]+)' property is true\. Sets the attribute to '([a-z0-9]+)' otherwise\./g,
211+
regexp: /Adds attribute '([\w-]+)=([\w\d]+)' to '([\w-]+)' component's part if '([\w-]+)' property is true\. Sets the attribute to '([\w\d]+)' otherwise\./g,
212212
testMethod: (parameters: TestMethod) => {
213213
const [
214214
attributeToBeAdded,
@@ -232,7 +232,7 @@ definitions.push({
232232

233233
// Adds attribute 'aria-haspopup=true' to 'root' component's part if 'menu' menu property is set.
234234
definitions.push({
235-
regexp: /Adds attribute '([a-zA-Z-]+)=([a-z0-9]+)' to '([a-z-]+)' component's part if '([a-z -]+)' property is set\./g,
235+
regexp: /Adds attribute '([\w-]+)=([\w\d]+)' to '([\w-]+)' component's part if '([\w-]+)' property is set\./g,
236236
testMethod: (parameters: TestMethod) => {
237237
const [
238238
attributeToBeAdded,
@@ -256,7 +256,7 @@ definitions.push({
256256

257257
// Example: Adds attribute 'aria-hidden=true', if there is no 'alt' property provided.
258258
definitions.push({
259-
regexp: /Adds attribute '([\w\-\w \s*]+)=([a-z]+)', if there is no 'alt' property provided\.+/g,
259+
regexp: /Adds attribute '([\w-]+)=(\w+)', if there is no 'alt' property provided\./g,
260260
testMethod: (parameters: TestMethod) => {
261261
const [attributeToBeAdded, attributeExpectedValue] = [...parameters.props]
262262
const property = {}
@@ -277,7 +277,7 @@ definitions.push({
277277

278278
// Example: Adds attribute 'aria-expanded=true' based on the property 'open' if the component has 'hasSubtree' property.
279279
definitions.push({
280-
regexp: /Adds attribute '([\w\-\w \s*]+)=([a-z]+)' based on the property '([a-z]+)' if the component has '([a-zA-Z]+)' property./g,
280+
regexp: /Adds attribute '([\w-]+)=(\w+)' based on the property '(\w+)' if the component has '(\w+)' property\./g,
281281
testMethod: (parameters: TestMethod) => {
282282
const [
283283
attributeToBeAdded,
@@ -319,7 +319,7 @@ definitions.push({
319319

320320
// Example: Adds role='button' if element type is other than 'button'.
321321
definitions.push({
322-
regexp: /Adds role='([a-z]+)' if element type is other than '[a-z]+'\.+/g,
322+
regexp: /Adds role='(\w+)' if element type is other than '\w+'\./g,
323323
testMethod: (parameters: TestMethod) => {
324324
const [roleToBeAdded] = [...parameters.props]
325325
const property = {}
@@ -338,7 +338,7 @@ definitions.push({
338338

339339
// Embeds FocusZone into component allowing arrow key navigation through the children of the component.
340340
definitions.push({
341-
regexp: /Embeds FocusZone into component allowing arrow key navigation through the children of the component\.+/g,
341+
regexp: /Embeds FocusZone into component allowing arrow key navigation through the children of the component\./g,
342342
testMethod: (parameters: TestMethod) => {
343343
const actualFocusZone = parameters.behavior({}).focusZone
344344

@@ -356,7 +356,7 @@ definitions.push({
356356

357357
// [Circular navigation] Embeds FocusZone into component allowing circular arrow key navigation through the children of the component.
358358
definitions.push({
359-
regexp: /Embeds FocusZone into component allowing circular arrow key navigation through the children of the component\.+/g,
359+
regexp: /Embeds FocusZone into component allowing circular arrow key navigation through the children of the component\./g,
360360
testMethod: (parameters: TestMethod) => {
361361
const actualFocusZone = parameters.behavior({}).focusZone
362362

@@ -374,7 +374,7 @@ definitions.push({
374374

375375
// Wraps component in FocusZone allowing arrow key navigation through the children of the component.
376376
definitions.push({
377-
regexp: /Wraps component in FocusZone allowing arrow key navigation through the children of the component\.+/g,
377+
regexp: /Wraps component in FocusZone allowing arrow key navigation through the children of the component\./g,
378378
testMethod: (parameters: TestMethod) => {
379379
const actualFocusZone = parameters.behavior({}).focusZone
380380

@@ -392,7 +392,7 @@ definitions.push({
392392

393393
// [Circular navigation] Wraps component in FocusZone allowing circular arrow key navigation through the children of the component.
394394
definitions.push({
395-
regexp: /Wraps component in FocusZone allowing circular arrow key navigation through the children of the component\.+/g,
395+
regexp: /Wraps component in FocusZone allowing circular arrow key navigation through the children of the component\./g,
396396
testMethod: (parameters: TestMethod) => {
397397
const actualFocusZone = parameters.behavior({}).focusZone
398398

@@ -440,7 +440,7 @@ definitions.push({
440440

441441
// Triggers 'click' action with 'Enter' or 'Spacebar' on 'root'.
442442
definitions.push({
443-
regexp: /Triggers '([a-z A-Z]+)' action with '([a-z A-Z]+)' or '([a-z A-Z]+)' on '([a-z A-Z]+)'\.+/g,
443+
regexp: /Triggers '(\w+)' action with '(\w+)' or '(\w+)' on '(\w+)'\./g,
444444
testMethod: (parameters: TestMethod) => {
445445
const [action, firstKey, secondKey, elementToPerformAction] = [...parameters.props]
446446
const property = {}
@@ -457,7 +457,7 @@ definitions.push({
457457

458458
// Triggers 'closeAllMenus' action with 'Escape' on 'root'.
459459
definitions.push({
460-
regexp: /Triggers '([a-z A-Z]+)' action with '([a-z A-Z]+)' on '([a-z A-Z]+)'\.+/g,
460+
regexp: /Triggers '(\w+)' action with '(\w+)' on '(\w+)'\./g,
461461
testMethod: (parameters: TestMethod) => {
462462
const [action, key, elementToPerformAction] = [...parameters.props]
463463
const property = {}
@@ -470,7 +470,7 @@ definitions.push({
470470

471471
// Triggers 'openMenu' action with 'ArrowDown' on 'root', when orientaton is horizontal.
472472
definitions.push({
473-
regexp: /Triggers '([a-z A-Z]+)' action with '([a-z A-Z]+)' on '([a-z A-Z]+)', when orientation is horizontal\.+/g,
473+
regexp: /Triggers '(\w+)' action with '(\w+)' on '([\w-]+)', when orientation is horizontal\./g,
474474
testMethod: (parameters: TestMethod) => {
475475
const [action, key, elementToPerformAction] = [...parameters.props]
476476
const property = {}
@@ -483,7 +483,7 @@ definitions.push({
483483

484484
// Triggers 'openMenu' action with 'ArrowRight' on 'root', when orientation is vertical.
485485
definitions.push({
486-
regexp: /Triggers '([a-z A-Z]+)' action with '([a-z A-Z]+)' on '([a-z A-Z]+)', when orientation is vertical\.+/g,
486+
regexp: /Triggers '(\w+)' action with '(\w+)' on '([\w-]+)', when orientation is vertical\./g,
487487
testMethod: (parameters: TestMethod) => {
488488
const [action, key, elementToPerformAction] = [...parameters.props]
489489
const propertyVertical = { vertical: true }
@@ -496,7 +496,7 @@ definitions.push({
496496

497497
// Implements roving tabIndex
498498
definitions.push({
499-
regexp: /Implements roving tabIndex.+/g,
499+
regexp: /Implements roving tabIndex\./g,
500500
testMethod: (parameters: TestMethod) => {
501501
const propertyChecked = { checked: true }
502502
const propertyNotChecked = { checked: false }

0 commit comments

Comments
 (0)