All files / server/utils header.js

60% Statements 6/10
25% Branches 1/4
100% Functions 2/2
60% Lines 6/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23    14x 14x 14x     10x   10x                       3x  
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