UNPKG

malwoden

Version:

![alt text](./coverage/badge-lines.svg) ![alt text](./coverage/badge-statements.svg) ![alt text](./coverage/badge-functions.svg) ![alt text](./coverage/badge-branches.svg)

74 lines 2.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var memory_terminal_1 = require("../terminal/memory-terminal"); var text_widget_1 = require("./text-widget"); describe("truncateText", function () { it("Can truncate text without ellipsis", function () { expect(text_widget_1.truncateText({ text: "Hello World", truncateAfter: 8, addEllipsis: false, })).toEqual("Hello Wo"); }); it("Can truncate text with ellipsis", function () { expect(text_widget_1.truncateText({ text: "Hello World", truncateAfter: 8, addEllipsis: true, })).toEqual("Hello..."); }); }); describe("splitAtWrap", function () { it("Can split a larger body of text", function () { var text = "Hello world how are you doing today?"; expect(text_widget_1.wrapText({ text: text, wrapAt: 10 })).toEqual([ "Hello", "world how", "are you", "doing", "today?", ]); }); it("will pass back an empty array for no text", function () { expect(text_widget_1.wrapText({ text: "", wrapAt: 4, })).toEqual([]); }); }); describe("TextWidget", function () { it("Can render basic text", function () { var terminal = new memory_terminal_1.MemoryTerminal({ width: 10, height: 10 }); var w = new text_widget_1.TextWidget({ initialState: { text: "Hello World" }, }); w.onDraw(); w.setTerminal(terminal); w.onDraw(); }); it("Can truncate text", function () { var terminal = new memory_terminal_1.MemoryTerminal({ width: 10, height: 10 }); var w = new text_widget_1.TextWidget({ initialState: { text: "Hello World", truncateAfter: 8 }, }); w.onDraw(); w.setTerminal(terminal); w.onDraw(); }); it("Can wrap text", function () { var terminal = new memory_terminal_1.MemoryTerminal({ width: 10, height: 10 }); var w = new text_widget_1.TextWidget({ initialState: { text: "Hello World", wrapAt: 8 }, }); w.onDraw(); w.setTerminal(); w.onDraw(); }); it("Can get lines", function () { var w = new text_widget_1.TextWidget({ initialState: { text: "Hello World" } }); expect(w["getLines"]("Hello World")).toEqual(["Hello World"]); w.setState({ wrapAt: 3 }); expect(w["getLines"]("Hello World")).toEqual(["Hello", "World"]); }); }); //# sourceMappingURL=text-widget.spec.js.map