mock-json-response
Version:
Configurable REST API response provider
23 lines (21 loc) • 621 B
JavaScript
class Header {
constructor(header, logicalOp, value) {
this.header = header;
this.logicalOp = logicalOp;
this.value = value;
}
match(matchTo) {
switch (this.logicalOp) {
case "equalTo":
return this.value === matchTo;
case "matches":
return RegExp(this.value).test(matchTo);
case "contains":
return this.value.includes(matchTo);
default:
console.log(this.logicalOp, 'is not defined');
return false;
}
}
}
module.exports = Header