e2ed
Version:
E2E testing framework over Playwright
32 lines (31 loc) • 937 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Route = void 0;
const internal_1 = require("./constants/internal");
/**
* Abstract route with base methods.
*/
class Route {
/**
* Immutable route parameters.
*/
routeParams;
constructor(...args) {
[this.routeParams] = args;
}
/**
* Returns the url of the route.
*/
getUrl() {
const originWithoutSlashesAtTheEnd = this.getOrigin().replace(internal_1.SLASHES_AT_THE_END_REGEXP, '');
const pathWithoutSlashesAtTheStart = this.getPath().replace(internal_1.SLASHES_AT_THE_START_REGEXP, '');
return `${originWithoutSlashesAtTheEnd}/${pathWithoutSlashesAtTheStart}`;
}
/**
* Returns `true` if url matches the page with given parameters, and `false` otherwise.
*/
isMatchUrl(url) {
return url.includes(this.getPath());
}
}
exports.Route = Route;