@cepharum/contextual-gherkin 1.0.1 → 1.0.2
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/context.js +5 -1
- package/package.json +14 -14
- package/steps/global-find.js +3 -0
- package/steps/local-state.js +3 -0
- package/steps/types.js +8 -11
package/lib/context.js
CHANGED
|
@@ -267,7 +267,11 @@ class Context {
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
const { query } = this.getSelector( "@" + name, false ) ?? {};
|
|
270
|
-
const matches = this.matches.
|
|
270
|
+
const matches = typeof value === "function" ? this.matches.filter( node => {
|
|
271
|
+
const actual = node.attributes.getNamedItem( name );
|
|
272
|
+
|
|
273
|
+
return value( actual == null ? undefined : actual.value );
|
|
274
|
+
}, { name: query ?? name, value } ) : this.matches.withAttribute( query ?? name, value );
|
|
271
275
|
|
|
272
276
|
return Promise.resolve( new this.constructor( this.testController, this, this.api, {
|
|
273
277
|
matches,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cepharum/contextual-gherkin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "flexible step definitions for Gherkin",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -24,22 +24,22 @@
|
|
|
24
24
|
"semver": "^7.5.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@cucumber/cucumber": "^
|
|
28
|
-
"@cucumber/cucumber-expressions": "^
|
|
29
|
-
"gherkin-testcafe": "^7.
|
|
30
|
-
"testcafe": "~3.
|
|
27
|
+
"@cucumber/cucumber": "^10.1.0",
|
|
28
|
+
"@cucumber/cucumber-expressions": "^17.0.1",
|
|
29
|
+
"gherkin-testcafe": "^7.2.0",
|
|
30
|
+
"testcafe": "~3.5.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@cucumber/cucumber": "^
|
|
34
|
-
"@cucumber/cucumber-expressions": "^
|
|
35
|
-
"eslint": "^8.
|
|
36
|
-
"eslint-config-cepharum": "^1.0.
|
|
37
|
-
"eslint-plugin-promise": "^6.1.
|
|
38
|
-
"gherkin-testcafe": "^7.
|
|
33
|
+
"@cucumber/cucumber": "^10.1.0",
|
|
34
|
+
"@cucumber/cucumber-expressions": "^17.0.1",
|
|
35
|
+
"eslint": "^8.56.0",
|
|
36
|
+
"eslint-config-cepharum": "^1.0.14",
|
|
37
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
38
|
+
"gherkin-testcafe": "^7.2.0",
|
|
39
39
|
"mocha": "^10.2.0",
|
|
40
|
-
"should": "^13.2.
|
|
41
|
-
"testcafe": "~3.
|
|
42
|
-
"vitepress": "^1.0.0-rc.
|
|
40
|
+
"should": "^13.2.3",
|
|
41
|
+
"testcafe": "~3.5.0",
|
|
42
|
+
"vitepress": "^1.0.0-rc.36"
|
|
43
43
|
},
|
|
44
44
|
"files": [
|
|
45
45
|
"lib",
|
package/steps/global-find.js
CHANGED
|
@@ -26,6 +26,9 @@ async function globalFind( testController, cardinal ) {
|
|
|
26
26
|
Given( "there is/are {cardinal-word} with ID/id {text-or-regexp}", ( t, [ cardinal, id ] ) => globalFindByAttribute( t, cardinal, "id", id ) );
|
|
27
27
|
Given( "there is/are {cardinal-word} with name {text-or-regexp}", ( t, [ cardinal, name ] ) => globalFindByAttribute( t, cardinal, "name", name ) );
|
|
28
28
|
Given( "there is/are {cardinal-word} named {text-or-regexp}", ( t, [ cardinal, name ] ) => globalFindByAttribute( t, cardinal, "name", name ) );
|
|
29
|
+
Given( "there is/are {cardinal-word} which is/are selected", ( t, [cardinal] ) => globalFindByAttribute( t, cardinal, "selected", v => v != null ) );
|
|
30
|
+
Given( "there is/are {cardinal-word} which is/are not selected", ( t, [cardinal] ) => globalFindByAttribute( t, cardinal, "selected", v => v == null ) );
|
|
31
|
+
Given( "there is/are {cardinal-word} which is/are unselected", ( t, [cardinal] ) => globalFindByAttribute( t, cardinal, "selected", v => v == null ) );
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
34
|
* Searches for element(s) matching a named attribute by value.
|
package/steps/local-state.js
CHANGED
|
@@ -6,6 +6,9 @@ const { Api } = require( "../lib/api" );
|
|
|
6
6
|
Then( "{contextual-word} has/have (the )ID/id {text-or-regexp}", ( t, [ context, text ] ) => localStateByAttribute( t, context, true, "id", text ) );
|
|
7
7
|
Then( "{contextual-word} has/have (the )name {text-or-regexp}", ( t, [ context, text ] ) => localStateByAttribute( t, context, true, "name", text ) );
|
|
8
8
|
Then( "{contextual-word} is/are named {text-or-regexp}", ( t, [ context, text ] ) => localStateByAttribute( t, context, true, "name", text ) );
|
|
9
|
+
Then( "{contextual-word} is/are selected", ( t, [context] ) => localStateByAttribute( t, context, true, "selected", v => v != null ) );
|
|
10
|
+
Then( "{contextual-word} is/are unselected", ( t, [context] ) => localStateByAttribute( t, context, true, "selected", v => v == null ) );
|
|
11
|
+
Then( "{contextual-word} is/are not selected", ( t, [context] ) => localStateByAttribute( t, context, true, "selected", v => v == null ) );
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Checks if some or all elements of an addressed match have a named attribute
|
package/steps/types.js
CHANGED
|
@@ -196,21 +196,18 @@ const customTypes = [
|
|
|
196
196
|
return new ContextualWord( formerLatter === "former" ? 1 : 0, undefined, undefined, undefined, false );
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
|
|
200
|
-
let plural = isPlural(
|
|
201
|
-
|
|
202
|
-
if ( plural ) {
|
|
203
|
-
_word = pluralize.singular( _word );
|
|
204
|
-
}
|
|
199
|
+
const originalWord = word[0] === '"' ? word.slice( 1, -1 ) : word;
|
|
200
|
+
let plural = isPlural( originalWord );
|
|
201
|
+
const normalizedWord = plural ? pluralize.singular( originalWord ) : originalWord;
|
|
205
202
|
|
|
206
203
|
if ( thisThat != null ) {
|
|
207
204
|
if ( plural != null && plural !== [ "these", "those" ].includes( thisThat ) ) {
|
|
208
|
-
console.warn( `ambiguous cardinality expressed in phrase "${thisThat} ${
|
|
205
|
+
console.warn( `ambiguous cardinality expressed in phrase "${thisThat} ${originalWord}"` );
|
|
209
206
|
|
|
210
207
|
plural = undefined;
|
|
211
208
|
}
|
|
212
209
|
|
|
213
|
-
return new ContextualWord( [ "this", "these" ].includes( thisThat ) ? 0 : 1,
|
|
210
|
+
return new ContextualWord( [ "this", "these" ].includes( thisThat ) ? 0 : 1, normalizedWord, plural, undefined, false );
|
|
214
211
|
}
|
|
215
212
|
|
|
216
213
|
if ( ordinal != null ) {
|
|
@@ -219,7 +216,7 @@ const customTypes = [
|
|
|
219
216
|
throw new TypeError( "invalid combination of former/latter with scoping reference" );
|
|
220
217
|
}
|
|
221
218
|
|
|
222
|
-
return new ContextualWord( ordinal === "former" ? 1 : 0,
|
|
219
|
+
return new ContextualWord( ordinal === "former" ? 1 : 0, normalizedWord, plural, undefined, false );
|
|
223
220
|
}
|
|
224
221
|
|
|
225
222
|
const subIndex = ( Ordinals[ordinal] ?? parseInt( ordinal, 10 ) ) - 1;
|
|
@@ -238,10 +235,10 @@ const customTypes = [
|
|
|
238
235
|
break;
|
|
239
236
|
}
|
|
240
237
|
|
|
241
|
-
return new ContextualWord( index,
|
|
238
|
+
return new ContextualWord( index, normalizedWord, plural, subIndex, true );
|
|
242
239
|
}
|
|
243
240
|
|
|
244
|
-
return new ContextualWord( 0,
|
|
241
|
+
return new ContextualWord( 0, normalizedWord, plural, undefined, false );
|
|
245
242
|
},
|
|
246
243
|
} ),
|
|
247
244
|
|