Skip to content

Commit

Permalink
feat(assertions): add "Then I see pathname" & "Then I see pathname co…
Browse files Browse the repository at this point in the history
…ntains"
  • Loading branch information
remarkablemark committed Feb 3, 2024
1 parent 2f30859 commit 6a64b96
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/assertions/location/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './hash';
export * from './location';
export * from './pathname';
export * from './search';
72 changes: 72 additions & 0 deletions src/assertions/location/pathname.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { DataTable, Then } from '@badeball/cypress-cucumber-preprocessor';

import { getOptions } from '../../utils';

/**
* Then I see pathname:
*
* ```gherkin
* Then I see pathname {string}
* ```
*
* @example
*
* ```gherkin
* Then I see pathname "/pathname"
* ```
*
* With [options](https://docs.cypress.io/api/commands/location#Arguments):
*
* ```gherkin
* Then I see pathname "/pathname"
* | log | true |
* | timeout | 4000 |
* ```
*
* @see
*
* - {@link Then_I_see_pathname_contains | Then I see pathname contains}
*/
export function Then_I_see_pathname(pathname: string, options?: DataTable) {
cy.location(getOptions(options)).should((location) => {
expect(location.pathname).to.equal(pathname);
});
}

Then('I see pathname {string}', Then_I_see_pathname);

/**
* Then I see pathname contains:
*
* ```gherkin
* Then I see pathname contains {string}
* ```
*
* @example
*
* ```gherkin
* Then I see pathname contains "pathname"
* ```
*
* With [options](https://docs.cypress.io/api/commands/location#Arguments):
*
* ```gherkin
* Then I see pathname contains "pathname"
* | log | true |
* | timeout | 4000 |
* ```
*
* @see
*
* - {@link Then_I_see_pathname | Then I see pathname}
*/
export function Then_I_see_pathname_contains(
pathname: string,
options?: DataTable,
) {
cy.location(getOptions(options)).should((location) => {
expect(location.pathname).to.contain(pathname);
});
}

Then('I see pathname contains {string}', Then_I_see_pathname_contains);

0 comments on commit 6a64b96

Please sign in to comment.