CoolFace
Apppublic

strong-tie/inbound-calls

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
chainable.test.js68 linesDownload Raw Back to test
1'use strict'2 3const { test } = require('tap')4const boot = require('..')5 6test('chainable standalone', (t) => {7  t.plan(5)8 9  const readyResult = boot()10    .use(function (ctx, opts, done) {11      t.pass('1st plugin')12      done()13    }).after(function (err, done) {14      t.error(err)15      t.pass('2nd after')16      done()17    }).ready(function () {18      t.pass('we are ready')19    })20  t.equal(readyResult, undefined)21})22 23test('chainable automatically binded', (t) => {24  t.plan(5)25 26  const app = {}27  boot(app)28 29  const readyResult = app30    .use(function (ctx, opts, done) {31      t.pass('1st plugin')32      done()33    }).after(function (err, done) {34      t.error(err)35      t.pass('2nd after')36      done()37    }).ready(function () {38      t.pass('we are ready')39    })40  t.equal(readyResult, undefined)41})42 43test('chainable standalone with server', (t) => {44  t.plan(6)45 46  const server = {}47  boot(server, {48    expose: {49      use: 'register'50    }51  })52 53  const readyResult = server.register(function (ctx, opts, done) {54    t.pass('1st plugin')55    done()56  }).after(function (err, done) {57    t.error(err)58    t.pass('2nd after')59    done()60  }).register(function (ctx, opts, done) {61    t.pass('3rd plugin')62    done()63  }).ready(function () {64    t.pass('we are ready')65  })66  t.equal(readyResult, undefined)67})68