CoolFace
Apppublic

strong-tie/inbound-calls

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
pretty-print.test.js76 linesDownload Raw Back to test
1'use strict'2 3const { test } = require('tap')4const boot = require('..')5 6test('pretty print', t => {7  t.plan(19)8 9  const app = boot()10  app11    .use(first)12    .use(duplicate, { count: 3 })13    .use(second).after(afterUse).after(after)14    .use(duplicate, { count: 2 })15    .use(third).after(after)16    .use(duplicate, { count: 1 })17 18  const linesExpected = [/^root \d+ ms$/,19    /^├── first \d+ ms$/,20    /^├─┬ duplicate \d+ ms$/,21    /^│ └─┬ duplicate \d+ ms$/,22    /^│ {3}└─┬ duplicate \d+ ms$/,23    /^│ {5}└── duplicate \d+ ms$/,24    /^├── second \d+ ms$/,25    /^├─┬ bound _after \d+ ms$/,26    /^│ └── afterInsider \d+ ms$/,27    /^├── bound _after \d+ ms$/,28    /^├─┬ duplicate \d+ ms$/,29    /^│ └─┬ duplicate \d+ ms$/,30    /^│ {3}└── duplicate \d+ ms$/,31    /^├── third \d+ ms$/,32    /^├── bound _after \d+ ms$/,33    /^└─┬ duplicate \d+ ms$/,34    /^ {2}└── duplicate \d+ ms$/,35    ''36  ]37 38  app.on('preReady', function show () {39    const print = app.prettyPrint()40    const lines = print.split('\n')41 42    t.equal(lines.length, linesExpected.length)43    lines.forEach((l, i) => {44      t.match(l, linesExpected[i])45    })46  })47 48  function first (s, opts, done) {49    done()50  }51  function second (s, opts, done) {52    done()53  }54  function third (s, opts, done) {55    done()56  }57  function after (err, cb) {58    cb(err)59  }60  function afterUse (err, cb) {61    app.use(afterInsider)62    cb(err)63  }64 65  function afterInsider (s, opts, done) {66    done()67  }68 69  function duplicate (instance, opts, cb) {70    if (opts.count > 0) {71      instance.use(duplicate, { count: opts.count - 1 })72    }73    setTimeout(cb, 20)74  }75})76