All files / src/helpers case.ts

100% Statements 9/9
100% Branches 3/3
100% Functions 2/2
100% Lines 8/8

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 172x   2x 29x 11x   11x   6x   3x   2x        
import { HandlebarsHelper, HelperConstructorBlock } from "./helper";
 
export const caseHelper: HelperConstructorBlock = ctx => {
    return new HandlebarsHelper("case", (type, rawV1): string => {
        const v1 = new String(rawV1).toString();
 
        switch (type) {
            case "upper":
                return v1.toUpperCase();
            case "lower":
                return v1.toLowerCase();
            default:
                throw new Error(`Invalid case type used with case: ${type}`);
        }
    });
};