!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/local/lib/node_modules/homebridge-config-ui-x/node_modules/avvio/test/   drwxr-xr-x
Free 13.16 GB of 57.97 GB (22.71%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     await-use.test.js (4.98 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
'use strict'

const { test } = require('tap')
const boot = require('..')

test('await use - nested plugins with same tick callbacks', async (t) => {
  const app = {}
  boot(app)

  t.plan(4)

  await app.use((f, opts, cb) => {
    t.pass('plugin init')
    app.use((f, opts, cb) => {
      t.pass('plugin2 init')
      cb()
    })
    cb()
  })
  t.pass('reachable')

  await app.ready()
  t.pass('reachable')
})

test('await use - nested plugins with future tick callbacks', async (t) => {
  const app = {}
  boot(app)

  t.plan(4)

  await app.use((f, opts, cb) => {
    t.pass('plugin init')
    app.use((f, opts, cb) => {
      t.pass('plugin2 init')
      setImmediate(cb)
    })
    setImmediate(cb)
  })
  t.pass('reachable')

  await app.ready()
  t.pass('reachable')
})

test('await use - nested async function plugins', async (t) => {
  const app = {}
  boot(app)

  t.plan(5)

  await app.use(async (f, opts) => {
    t.pass('plugin init')
    await app.use(async (f, opts) => {
      t.pass('plugin2 init')
    })
    t.pass('reachable')
  })
  t.pass('reachable')

  await app.ready()
  t.pass('reachable')
})

test('await use - promise returning function plugins + promise chaining', async (t) => {
  const app = {}
  boot(app)

  t.plan(6)

  await app.use((f, opts) => {
    t.pass('plugin init')
    return app.use((f, opts) => {
      t.pass('plugin2 init')
      return Promise.resolve()
    }).then(() => {
      t.pass('reachable')
      return 'test'
    }).then((val) => {
      t.equal(val, 'test')
    })
  })
  t.pass('reachable')

  await app.ready()
  t.pass('reachable')
})

test('await use - await and use chaining', async (t) => {
  const app = {}
  boot(app)

  t.plan(3)

  app.use(async (f, opts, cb) => {
    await app.use(async (f, opts) => {
      t.pass('plugin init')
    }).use(async (f, opts) => {
      t.pass('plugin2 init')
    })
  })

  await app.ready()
  t.pass('reachable')
})

function thenableRejects (t, thenable, err, msg) {
  return t.rejects(async () => { await thenable }, err, msg)
}

test('await use - error handling, async throw', async (t) => {
  const app = {}
  boot(app)

  t.plan(2)

  await thenableRejects(t, app.use(async (f, opts) => {
    throw Error('kaboom')
  }), Error('kaboom'))

  await t.rejects(app.ready(), Error('kaboom'))
})

test('await use - error handling, async throw, nested', async (t) => {
  const app = {}
  boot(app)

  t.plan(2)

  await thenableRejects(t, app.use(async function a (f, opts) {
    await app.use(async function b (f, opts) {
      throw Error('kaboom')
    })
  }, Error('kaboom')), 'b')

  t.rejects(() => app.ready(), Error('kaboom'))
})

test('await use - error handling, same tick cb err', async (t) => {
  const app = {}
  boot(app)

  t.plan(2)

  await thenableRejects(t, app.use((f, opts, cb) => {
    cb(Error('kaboom'))
  }), Error('kaboom'))

  t.rejects(() => app.ready(), Error('kaboom'))
})

test('await use - error handling, same tick cb err, nested', async (t) => {
  const app = {}
  boot(app)

  t.plan(2)

  await thenableRejects(t, app.use((f, opts, cb) => {
    app.use((f, opts, cb) => {
      cb(Error('kaboom'))
    })
    cb()
  }), Error('kaboom'))

  t.rejects(() => app.ready(), Error('kaboom'))
})

test('await use - error handling, future tick cb err', async (t) => {
  const app = {}
  boot(app)

  t.plan(2)

  await thenableRejects(t, app.use((f, opts, cb) => {
    setImmediate(() => { cb(Error('kaboom')) })
  }), Error('kaboom'))

  t.rejects(() => app.ready(), Error('kaboom'))
})

test('await use - error handling, future tick cb err, nested', async (t) => {
  const app = {}
  boot(app)

  t.plan(2)

  await thenableRejects(t, app.use((f, opts, cb) => {
    app.use((f, opts, cb) => {
      setImmediate(() => { cb(Error('kaboom')) })
    })
    cb()
  }), Error('kaboom'))

  t.rejects(() => app.ready(), Error('kaboom'))
})

test('mixed await use and non-awaited use ', async (t) => {
  const app = {}
  boot(app)
  t.plan(16)

  let firstLoaded = false
  let secondLoaded = false
  let thirdLoaded = false
  let fourthLoaded = false

  await app.use(first)
  t.ok(firstLoaded, 'first is loaded')
  t.notOk(secondLoaded, 'second is not loaded')
  t.notOk(thirdLoaded, 'third is not loaded')
  t.notOk(fourthLoaded, 'fourth is not loaded')
  app.use(second)
  t.ok(firstLoaded, 'first is loaded')
  t.notOk(secondLoaded, 'second is not loaded')
  t.notOk(thirdLoaded, 'third is not loaded')
  t.notOk(fourthLoaded, 'fourth is not loaded')
  await app.use(third)
  t.ok(firstLoaded, 'first is loaded')
  t.ok(secondLoaded, 'second is loaded')
  t.ok(thirdLoaded, 'third is loaded')
  t.ok(fourthLoaded, 'fourth is loaded')
  await app.ready()
  t.ok(firstLoaded, 'first is loaded')
  t.ok(secondLoaded, 'second is loaded')
  t.ok(thirdLoaded, 'third is loaded')
  t.ok(fourthLoaded, 'fourth is loaded')

  async function first () {
    firstLoaded = true
  }

  async function second () {
    secondLoaded = true
  }

  async function third (app) {
    thirdLoaded = true
    app.use(fourth)
  }

  async function fourth () {
    fourthLoaded = true
  }
})

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0084 ]--