"use strict" var test = require("tap").test var ProgressBar = require("../progress-bar.js") var cursor = [] var C var bar = new ProgressBar({theme: ProgressBar.ascii, maxUpdateFrequency: 0}, C = { show: function () { cursor.push(["show"]) return C }, hide: function () { cursor.push(["hide"]) return C }, up: function (lines) { cursor.push(["up",lines]) return C }, horizontalAbsolute: function (col) { cursor.push(["horizontalAbsolute", col]) return C }, eraseLine: function () { cursor.push(["eraseLine"]) return C }, write: function (line) { cursor.push(["write", line]) return C } }) function isOutput(t, msg, output) { var tests = [] for (var ii = 0; ii P | |----|\n' ], [ 'show' ] ]) }) test("window resizing", function (t) { t.plan(16) process.stderr.isTTY = true process.stdout.columns = 32 bar.show("NAME", 0.1) cursor = [] bar.last = new Date(0) bar.pulse() isOutput(t, "32 columns", [ [ 'up', 1 ], [ 'hide' ], [ 'horizontalAbsolute', 0 ], [ 'write', 'NAME / |##------------------|\n' ], [ 'show' ] ]) process.stdout.columns = 16 bar.show("NAME", 0.5) cursor = [] bar.last = new Date(0) bar.pulse() isOutput(t, "16 columns", [ [ 'up', 1 ], [ 'hide' ], [ 'horizontalAbsolute', 0 ], [ 'write', 'NAME - |##--|\n' ], [ 'show' ] ]); });