How to use tman - 10 common examples

To help you get started, we’ve selected a few tman examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thunks / thunk-redis / test / commands / chaos.js View on Github external
tman.suite('chaos test', function () {
  const client = redis.createClient()
  const clientP = redis.createClient({
    usePromise: true
  })
  const len = 10000
  const tasks = []
  for (let i = 0; i < len; i++) tasks.push(i)

  function getClient () {
    // use thunk API or promise API randomly
    return Math.floor(Math.random() * 10) % 2 ? client : clientP
  }

  tman.it('create 10000 users', function * () {
    assert((yield client.flushall()) === 'OK')
    yield tasks.map((value, index) => createUser('U' + index))
    assert((yield client.zcard('userScore')) === len)

    function createUser (id) {
      const time = Date.now()
      const user = {
        id: id,
        name: 'user_' + id,
        email: id + '@test.com',
        score: 0,
        issues: [],
        createdAt: time,
        updatedAt: time
      }
github fidm / x509 / test / pem.ts View on Github external
'use strict'
// **Github:** https://github.com/fidm/x509
//
// **License:** MIT

import fs from 'fs'
import { strictEqual, ok, throws } from 'assert'
import { suite, it } from 'tman'
import { PEM } from '../src/pem'

suite('PEM', function () {
  it('should work', function () {
    const crtData = fs.readFileSync('./test/cert/github.crt')
    const pems = PEM.parse(crtData)
    strictEqual(pems.length, 1)
    strictEqual(pems[0].type, 'CERTIFICATE')
    strictEqual(pems[0].procType, '')
    strictEqual(pems[0].getHeader('DEK-Info'), '')
    strictEqual(pems[0].toString(), crtData.toString())
    ok(pems[0].body instanceof Buffer)
  })

  it('should throw error if no block', function () {
    throws(() => PEM.parse(Buffer.alloc(0)))
  })
})
github thunks / thunk-redis / test / cluster.js View on Github external
client.multi(),
        client.set(i, i),
        client.get(i),
        client.exec()
      ]
      console.log(111, res)
      assert.strictEqual(res[0], 'OK')
      assert.strictEqual(res[1], 'QUEUED')
      assert.strictEqual(res[2], 'QUEUED')
      assert.strictEqual(res[3][0], 'OK')
      assert.strictEqual(res[3][1], i + '')
      if (!(i % 500)) process.stdout.write('.')
    }
  })

  tman.it('evalauto', function * () {
    const task = []
    let len = count
    while (len--) addTask(len)
    yield thunk.all(task)

    function addTask (index) {
      task.push(function * () {
        const res = yield client.evalauto('return KEYS[1]', 1, index)
        assert.strictEqual(+res, index)
        if (!(index % 500)) process.stdout.write('.')
        return +res
      })
    }
  })

  tman.it.skip('kill a master', function * () {
github teambition / merge2 / test / index.js View on Github external
function test (merge2) {
  tman.suite('merge2', function () {
    tman.it('merge2(read1, read2, through3)', function (done) {
      const options = { objectMode: true }
      const result = []
      const read1 = fakeReadStream(options)
      const read2 = fakeReadStream(options)
      const through3 = through.obj()

      const mergeStream = merge2(read1, read2, through3)

      read1.push(1)
      thunk.delay(100)(function () {
        read1.push(2)
        read1.push(null)
      })
      read2.push(3)
      thunk.delay(10)(function () {
github toajs / toa / test / request / acceptsCharsets.js View on Github external
tman.suite('ctx.acceptsCharsets()', function () {
  tman.suite('with no arguments', function () {
    tman.suite('when Accept-Charset is populated', function () {
      tman.it('should return accepted types', function () {
        let ctx = context()
        ctx.req.headers['accept-charset'] = 'utf-8, iso-8859-1;q=0.2, utf-7;q=0.5'
        assert.deepStrictEqual(ctx.acceptsCharsets(), ['utf-8', 'utf-7', 'iso-8859-1'])
      })
    })
  })

  tman.suite('with multiple arguments', function () {
    tman.suite('when Accept-Charset is populated', function () {
      tman.suite('if any types match', function () {
        tman.it('should return the best fit', function () {
          let ctx = context()
          ctx.req.headers['accept-charset'] = 'utf-8, iso-8859-1;q=0.2, utf-7;q=0.5'
          assert.strictEqual(ctx.acceptsCharsets('utf-7', 'utf-8'), 'utf-8')
github toajs / toa / test / request / acceptsLanguages.js View on Github external
tman.suite('ctx.acceptsLanguages(langs)', function () {
  tman.suite('with no arguments', function () {
    tman.suite('when Accept-Language is populated', function () {
      tman.it('should return accepted types', function () {
        let ctx = context()
        ctx.req.headers['accept-language'] = 'en;q=0.8, es, pt'
        assert.deepStrictEqual(ctx.acceptsLanguages(), ['es', 'pt', 'en'])
      })
    })
  })

  tman.suite('with multiple arguments', function () {
    tman.suite('when Accept-Language is populated', function () {
      tman.suite('if any types types match', function () {
        tman.it('should return the best fit', function () {
          let ctx = context()
          ctx.req.headers['accept-language'] = 'en;q=0.8, es, pt'
          assert.strictEqual(ctx.acceptsLanguages('es', 'en'), 'es')
github toajs / toa / test / request / acceptsEncodings.js View on Github external
tman.suite('ctx.acceptsEncodings()', function () {
  tman.suite('with no arguments', function () {
    tman.suite('when Accept-Encoding is populated', function () {
      tman.it('should return accepted types', function () {
        let ctx = context()
        ctx.req.headers['accept-encoding'] = 'gzip, compress;q=0.2'
        assert.deepStrictEqual(ctx.acceptsEncodings(), ['gzip', 'compress', 'identity'])
        assert.strictEqual(ctx.acceptsEncodings('gzip', 'compress'), 'gzip')
      })
    })

    tman.suite('when Accept-Encoding is not populated', function () {
      tman.it('should return identity', function () {
        let ctx = context()
        assert.deepStrictEqual(ctx.acceptsEncodings(), ['identity'])
        assert.strictEqual(ctx.acceptsEncodings('gzip', 'deflate', 'identity'), 'identity')
      })
    })
github toajs / toa / test / request / accepts.js View on Github external
tman.suite('ctx.accepts(types)', function () {
  tman.suite('with no arguments', function () {
    tman.suite('when Accept is populated', function () {
      tman.it('should return all accepted types', function () {
        let ctx = context()
        ctx.req.headers.accept = 'application/*;q=0.2, image/jpeg;q=0.8, text/html, text/plain'
        assert.deepStrictEqual(ctx.accepts(), ['text/html', 'text/plain', 'image/jpeg', 'application/*'])
      })
    })
  })

  tman.suite('with no valid types', function () {
    tman.suite('when Accept is populated', function () {
      tman.it('should return false', function () {
        let ctx = context()
        ctx.req.headers.accept = 'application/*;q=0.2, image/jpeg;q=0.8, text/html, text/plain'
        assert.strictEqual(ctx.accepts('image/png', 'image/tiff'), false)
      })
github toajs / toa / test / response / is.js View on Github external
tman.suite('when no type is set', function () {
    tman.it('should return false', function () {
      let res = context().response

      assert.strictEqual(res.is(), false)
      assert.strictEqual(res.is('html'), false)
    })
  })
github toajs / toa / test / request / acceptsCharsets.js View on Github external
tman.suite('if no types match', function () {
        tman.it('should return false', function () {
          let ctx = context()
          ctx.req.headers['accept-charset'] = 'utf-8, iso-8859-1;q=0.2, utf-7;q=0.5'
          assert.strictEqual(ctx.acceptsCharsets('utf-16'), false)
        })
      })
    })

tman

T-man: Super test manager for JavaScript.

MIT
Latest version published 5 years ago

Package Health Score

39 / 100
Full package analysis

Popular tman functions