Skip to content

Commit

Permalink
refactor(queries): modularize last from element
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Nov 30, 2023
1 parent 6476752 commit 6c4be41
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 34 deletions.
34 changes: 0 additions & 34 deletions src/queries/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,6 @@ import { When } from '@badeball/cypress-cucumber-preprocessor';

import { getCypressElement, setCypressElement } from '../utils';

/**
* When I get last element:
*
* ```gherkin
* When I get last element
* ```
*
* @example
*
* ```gherkin
* When I get last element
* ```
*
* @remarks
*
* This follows steps like {@link When_I_find_links_by_text | "When I find links by text"} and precedes steps like {@link When_I_click | "When I click"}. For example:
*
* ```gherkin
* When I find links by text "Link"
* And I get last element
* And I click
* ```
*
* @see
*
* - {@link When_I_get_first_element | When I get first element}
* - {@link When_I_get_nth_element | When I get nth element}
*/
export function When_I_get_last_element() {
setCypressElement(getCypressElement().last());
}

When('I get last element', When_I_get_last_element);

/**
* When I get nth element:
*
Expand Down
1 change: 1 addition & 0 deletions src/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from './get';
export * from './heading';
export * from './input';
export * from './label';
export * from './last';
export * from './link';
export * from './name';
export * from './placeholder';
Expand Down
37 changes: 37 additions & 0 deletions src/queries/last.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { When } from '@badeball/cypress-cucumber-preprocessor';

import { getCypressElement, setCypressElement } from '../utils';

/**
* When I get last element:
*
* ```gherkin
* When I get last element
* ```
*
* @example
*
* ```gherkin
* When I get last element
* ```
*
* @remarks
*
* This follows steps like {@link When_I_find_links_by_text | "When I find links by text"} and precedes steps like {@link When_I_click | "When I click"}. For example:
*
* ```gherkin
* When I find links by text "Link"
* And I get last element
* And I click
* ```
*
* @see
*
* - {@link When_I_get_nth_element | When I get nth element}
* - {@link When_I_get_first_element | When I get first element}
*/
export function When_I_get_last_element() {
setCypressElement(getCypressElement().last());
}

When('I get last element', When_I_get_last_element);

0 comments on commit 6c4be41

Please sign in to comment.