import {CustomExpect} from "../../common-helpers/custom-expect";
import {browser, $, $$, expect} from '@wdio/globals'

/**
 * The expected path has to be full string after the domain.
 * Example : http://localhost:3000/venues/ ---->expected path is "/venues/"
 */
export default async function (falseCase: boolean, expectedPath: string) {
    let currentUrl = (await browser.getUrl()).replace(/http(s?):\/\//, '');
    const domain = `${currentUrl.split('/')[0]}`;

    currentUrl = currentUrl.replace(domain, '');

    if (falseCase) {
        CustomExpect.expectNotToEqual(currentUrl, expectedPath, `Current URL "${currentUrl}" and expected path "${expectedPath}" are matching`)
    } else {
        CustomExpect.expectToEqual(currentUrl, expectedPath, `Current URL "${currentUrl}" and expected path "${expectedPath}" are not matching`)
    }
};
