From 87adae3c0678f8982068379f0f0767cf3a1679f9 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 24 Dec 2022 16:20:53 -0500 Subject: [PATCH] feat(assertions): add "Then I see hash" and "Then I see hash contains" --- src/assertions/hash.ts | 51 +++++++++++++++++++++++++++++++++++++++++ src/assertions/index.ts | 1 + 2 files changed, 52 insertions(+) create mode 100644 src/assertions/hash.ts diff --git a/src/assertions/hash.ts b/src/assertions/hash.ts new file mode 100644 index 000000000..fab1ae1d0 --- /dev/null +++ b/src/assertions/hash.ts @@ -0,0 +1,51 @@ +import { Then } from '@badeball/cypress-cucumber-preprocessor'; + +/** + * Then I see hash: + * + * ```gherkin + * Then I see hash {string} + * ``` + * + * @example + * + * ```gherkin + * Then I see hash "#hash" + * ``` + * + * @remarks + * + * The URL hash includes the `#` character. + * + * @see + * + * - {@link Then_I_see_hash_contains | Then I see hash contains} + */ +export function Then_I_see_hash(hash: string) { + cy.hash().should('equal', hash); +} + +Then('I see hash {string}', Then_I_see_hash); + +/** + * Then I see hash contains: + * + * ```gherkin + * Then I see hash contains {string} + * ``` + * + * @example + * + * ```gherkin + * Then I see hash contains "hash" + * ``` + * + * @see + * + * - {@link Then_I_see_hash | Then I see hash} + */ +export function Then_I_see_hash_contains(hash: string) { + cy.hash().should('contain', hash); +} + +Then('I see hash contains {string}', Then_I_see_hash_contains); diff --git a/src/assertions/index.ts b/src/assertions/index.ts index 4907a4286..46d450e42 100644 --- a/src/assertions/index.ts +++ b/src/assertions/index.ts @@ -1,2 +1,3 @@ +export * from './hash'; export * from './text'; export * from './url';