import {Given, Then} from "@cucumber/cucumber";
import checkTitle from "../helpers/framework-helpers/check/checkTitle";
import checkTitleContains from "../helpers/framework-helpers/check/checkTitleContains";
import checkUrl from "../helpers/framework-helpers/check/checkURL";
import checkURLPath from "../helpers/framework-helpers/check/checkURLPath";
import checkInURLPath from "../helpers/framework-helpers/check/checkInURLPath";

Given(/^the page title is( not)? "([^"]*)?"$/, async (falseCase: boolean, expectedTitle: string) => {
    console.log(`The page title is ${falseCase ? 'not' : ''} ${expectedTitle}`);
    await checkTitle(falseCase, expectedTitle);
});

Given(/^the page title( not)? contains "([^"]*)?"$/, async (falseCase: boolean, expectedTitle: string) => {
    console.log(`The page title ${falseCase ? 'not' : ''} contains ${expectedTitle}`);
    await checkTitleContains(falseCase, expectedTitle);
});

Given(/^the page url is( not)? "([^"]*)?"$/, async (falseCase: boolean, expectedUrl: string) => {
    console.log(`the page url is ${falseCase ? 'not' : ''} ${expectedUrl}`);
    await checkUrl(falseCase, expectedUrl);
});

Then(/^I expect that the path is( not)? "([^"]*)?"$/, async (falseCase: boolean, expectedUrl: string) => {
    console.log(`I expect that the path is ${falseCase ? 'not' : ''} ${expectedUrl}`);
    await checkURLPath(falseCase, expectedUrl);
});

Then(/^I expect that the path( not)? contains "([^"]*)?"$/, async (falseCase: boolean, expectedUrl: string) => {
    console.log(`I expect that the path ${falseCase ? 'not' : ''} contains ${expectedUrl}`);
    await checkInURLPath(falseCase, expectedUrl);
});
