UNPKG

skutter

Version:

Skutter: Opinionated BDD Browser based test framework

26 lines (25 loc) 929 B
"use strict"; class BoxWrapper { static wrap(message, indentation = 0, character = "-") { if (!message && message !== "") { throw new Error("[BoxWrapper].[wrap] message is not specified"); } if (indentation === undefined || indentation === null) { throw new Error("[BoxWrapper].[wrap] indentation is not specified"); } if (!character || character.length !== 1) { throw new Error("[BoxWrapper].[wrap] character is not specified"); } if (message === "") { return []; } let indent = Array(indentation + 1).join(" "); let lines = "+" + Array(message.length + 3).join(character) + "+"; let result = []; result.push(indent + lines); result.push(indent + "| " + message + " |"); result.push(indent + lines); return result; } } exports.BoxWrapper = BoxWrapper;