-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(assertions): add "Then I see location"
- Loading branch information
1 parent
561a0fa
commit 2099ce9
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './hash'; | ||
export * from './location'; | ||
export * from './search'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { DataTable, Then } from '@badeball/cypress-cucumber-preprocessor'; | ||
|
||
import { getOptions } from '../../utils'; | ||
|
||
/** | ||
* Then I see location: | ||
* | ||
* ```gherkin | ||
* Then I see location | ||
* | hash | {string} | | ||
* | host | {string} | | ||
* | hostname | {string} | | ||
* | href | {string} | | ||
* | origin | {string} | | ||
* | pathname | {string} | | ||
* | port | {string} | | ||
* | protocol | {string} | | ||
* | search | {string} | | ||
* ``` | ||
* | ||
* @example | ||
* | ||
* Make assertions about every location property: | ||
* | ||
* ```gherkin | ||
* Then I see location | ||
* | hash | #hash | | ||
* | host | localhost:8081 | | ||
* | hostname | localhost | | ||
* | href | http://localhost:8081/commands/querying?key=value#hash | | ||
* | origin | http://localhost:8081 | | ||
* | pathname | /commands/querying | | ||
* | port | 8081 | | ||
* | protocol | http: | | ||
* | search | ?key=value | | ||
* ``` | ||
* | ||
* Check location for query params and pathname: | ||
* | ||
* ```gherkin | ||
* Then I see location | ||
* | search | ?key=value | | ||
* | pathname | /commands/querying | | ||
* ``` | ||
* | ||
* @see | ||
* | ||
* - {@link Then_I_see_hash | Then I see hash} | ||
* - {@link Then_I_see_search | Then I see search} | ||
*/ | ||
export function Then_I_see_location(location: DataTable) { | ||
const loc = getOptions(location); | ||
|
||
if (typeof loc?.port === 'number') { | ||
loc.port = String(loc.port); | ||
} | ||
|
||
cy.location().should('include', loc); | ||
} | ||
|
||
Then('I see location', Then_I_see_location); |