How to use the tman.suite function in tman

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 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 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 thunks / thunks / test / thunk.js View on Github external
}, 100)
            },
            function (callback) {
              setTimeout(function () {
                callback(null, 'b')
              }, 10)
            }
          ])
        })(function (error, value) {
          should(error).be.equal(null)
          should(value).be.equal('b')
        })(done)
      })
    })

    tman.suite('thunk.thunkify()', function () {
      function test (a, b, c, callback) {
        callback(a, b, c, this)
      }

      tman.it('thunk.thunkify()', function (done) {
        var thunk = thunks()
        var thunkTest = thunk.thunkify(test)
        thunkTest(1, 2, 3)(function (error, value) {
          should(error).be.equal(1)
          should(value).be.equal(undefined)
          return thunkTest(null, 2, x)
        })(function (error, value) {
          should(error).be.equal(null)
          should(value[0]).be.equal(2)
          should(value[1]).be.equal(x)
          should(value[2]).be.equal(this)
github teambition / mejs / test / ejs.js View on Github external
assert.strictEqual(mejs.render('index'), '0')

    mejs = tplStr2Mejs('<%- 0 %>')
    assert.strictEqual(mejs.render('index'), '0')
  })

  tman.it('false renders something escaped', function () {
    let mejs = tplStr2Mejs('<%= false %>')
    assert.strictEqual(mejs.render('index'), 'false')

    mejs = tplStr2Mejs('<%- false %>')
    assert.strictEqual(mejs.render('index'), 'false')
  })
})

tman.suite('<%', function () {
  tman.it('without semicolons', function () {
    let mejs = fixtureMejs('no.semicolons.ejs')
    assert.strictEqual(mejs.render('no.semicolons'), fixtureFile('no.semicolons.html'))
  })
})

tman.suite('<%=', function () {
  tman.it('escape &
github teambition / mejs / test / ejs.js View on Github external
let mejs = tplStr2Mejs('<%= false %>')
    assert.strictEqual(mejs.render('index'), 'false')

    mejs = tplStr2Mejs('<%- false %>')
    assert.strictEqual(mejs.render('index'), 'false')
  })
})

tman.suite('<%', function () {
  tman.it('without semicolons', function () {
    let mejs = fixtureMejs('no.semicolons.ejs')
    assert.strictEqual(mejs.render('no.semicolons'), fixtureFile('no.semicolons.html'))
  })
})

tman.suite('<%=', function () {
  tman.it('escape &
github teambition / mejs / test / ejs.js View on Github external
assert.equal(mejs.render('index', {users: users}), expectedResult)
  })

  tman.it('works with windows style', function () {
    let mejs = tplStr2Mejs('<ul>&lt;% -%&gt;\r\n' +
      '&lt;% it.users.forEach(function(user){ -%&gt;\r\n' +
      '<li>&lt;%= user.name -%&gt;</li>\r\n' +
      '&lt;% }) -%&gt;\r\n' +
      '</ul>&lt;% -%&gt;\r\n')

    let expectedResult = '<ul><li>geddy</li>\r\n<li>neil</li>\r\n<li>alex</li>\r\n</ul>'
    assert.equal(mejs.render('index', {users: users}), expectedResult)
  })
})

tman.suite('&lt;%%', function () {
  tman.it('produce literals', function () {
    let mejs = tplStr2Mejs('&lt;%%- "foo" %&gt;')
    assert.strictEqual(mejs.render('index'), '&lt;%- "foo" %&gt;')
  })

  tman.it('work without an end tag', function () {
    let mejs = tplStr2Mejs('&lt;%%')
    assert.strictEqual(mejs.render('index'), '&lt;%')

    mejs = fixtureMejs('literal.ejs', {delimiter: ' '})
    assert.strictEqual(mejs.render('literal'), fixtureFile('literal.html'))
  })
})

tman.suite('%%&gt;', function () {
  tman.it('produce literal', function () {

tman

T-man: Super test manager for JavaScript.

MIT
Latest version published 4 years ago

Package Health Score

39 / 100
Full package analysis

Popular tman functions