How to use the tap.ok function in tap

To help you get started, we’ve selected a few tap 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 npm / arborist / test / dep-valid.js View on Github external
}, 'file:/some/path', {}), 'links must point at intended target')

t.notOk(depValid({
  realpath: '/some/path'
}, 'file:/some/path', {}), 'file:// must be a link')


t.ok(depValid({
  name: 'foo',
  resolved: 'git://host/repo#somebranch',
  package: {
    version: '1.2.3',
  },
}, 'git://host/repo#semver:1.x', {}), 'git url with semver range')

t.ok(depValid({
  name: 'foo',
  package: {
    name: 'bar',
    version: '1.2.3',
  },
}, 'npm:bar@1.2.3', {}), 'alias is ok')

t.ok(depValid({
  resolved: 'https://registry/abbrev-1.1.1.tgz',
  package: {},
}, 'https://registry/abbrev-1.1.1.tgz', {}), 'remote url match')

t.ok(depValid({
  resolved: 'git+ssh://git@github.com/foo/bar',
  package: {},
}, 'git+ssh://git@github.com/foo/bar.git', {}), 'matching _from saveSpec')
github ubahnverleih / simple-opening-hours / test / parser.tests.js View on Github external
const t = require("tap")

const { default: oh, map } = require("../dist/simple-opening-hours")

t.ok((new oh("24/7")).isOpen())
t.ok((new oh(" 24/7")).isOpen())
t.ok((new oh(" 24/7 ")).isOpen())
t.ok((new oh("24/7 ")).isOpen())
t.ok((new oh("24 / 7")).isOpen())
t.ok((new oh("24/7")).getTable())
t.ok((new oh("24/7")).alwaysOpen)

t.notOk((new oh("off")).isOpen())
t.notOk((new oh(" off")).isOpen())
t.notOk((new oh("off ")).isOpen())
t.notOk((new oh(" off ")).isOpen())
t.ok((new oh("off")).alwaysClosed)

t.ok((new oh("Mo-Sa 06:00-22:00")).isOpen(new Date('2016-10-01 18:00')))
t.notOk((new oh("Mo 06:00-22:00")).isOpen(new Date('2016-10-01 18:00')))
t.ok((new oh("Mo-Sa 09:00+")).isOpen(new Date('2016-10-01 18:00')))
t.notOk((new oh("Mo-Sa off")).isOpen(new Date('2016-10-01 18:00')))
t.notOk((new oh("Mo-Sa 06:00-22:00")).isOpen(new Date('2016-10-01 05:00')))
t.ok((new oh("Mo-Sa 06:00-22:00")).getTable())

t.test("Simple Time tables", t => {
github dmester / jdenticon / test / node / toPng.js View on Github external
"use strict";

var tap = require("tap");
var jdenticon = require("../../src/node");

var pngHash = jdenticon.toPng("Icon1", 100);
var pngValue = jdenticon.toPng("9faff4f3d6d7d75577ce810ec6d6a06be49c3a5a", 100);

tap.ok(pngHash);
tap.ok(pngHash instanceof Buffer);
tap.ok(pngHash.length > 500);

tap.ok(pngValue);
tap.ok(pngValue instanceof Buffer);
tap.ok(pngValue.length > 500);

tap.ok(pngHash.equals(pngValue));
github schwarzkopfb / sse-broadcast / test / headers.js View on Github external
res.on('end', function () {
            test.ok(compare(expected, res.headers), 'expected headers should be set')
            doTest(n)
        })
        res.resume()
github mcollina / bhdr / test / cli-json.js View on Github external
],
  'benchmarks/benchB.js': [
    'a',
    'b',
    'a',
    'b'
  ]
}

t.plan(Object.keys(expected).reduce((acc, key) => acc + expected[key].length, 0) * 2 + lines.length + 1)

try {
  fs.unlinkSync(file)
  t.pass('cleaned correctly')
} catch (err) {
  t.ok(err, 'no file to clean')
}

const args = [
  path.join(__dirname, '../bin.js'),
  '--out',
  file,
  path.join(__dirname, 'benchmarks')
]

const child = childProcess.spawn(process.execPath, args, {
  cwd: __dirname,
  env: process.env,
  stdio: ['ignore', 'pipe', 'pipe'],
  detached: false
})
github prantlf / nettime / tests / nettime.js View on Github external
test.equal(Object.keys(result).length, resultCount)
  const httpVersion = options.httpVersion || '1.1'
  if (httpVersion === '1.0') {
    result.httpVersion = '1.0'
  }
  test.equal(result.httpVersion, httpVersion)
  test.equal(lastRequest.httpVersion, httpVersion)
  const { timings } = result
  test.equal(typeof timings, 'object')
  checkTiming(timings.socketOpen)
  const { tcpConnection, firstByte } = timings
  checkTiming(tcpConnection)
  checkTiming(firstByte)
  checkTiming(timings.contentTransfer)
  checkTiming(timings.socketClose)
  test.ok(getTestDuration(tcpConnection, firstByte) >= 1 * 1e6)
  return result
}
github auchenberg / volkswagen / test / tap.js View on Github external
tap.error(new Error('this is not the error you\'re looking for'))
tap.equal('foo', 'bar')
tap.not('foo', 'foo')
tap.same({ foo: 1 }, { bar: 1 })
tap.notSame({ foo: 1 }, { foo: 1 })
tap.strictSame([null], [undefined])
tap.strictNotSame([42], [42])
tap.match({ foo: 'bar' }, { foo: /baz/ })
tap.notMatch({ foo: 'bar' }, { foo: /^bar$/ })
tap.type(new Date(), Number)
tap.throws(function () {})
tap.doesNotThrow(function () {
  throw new Error('bang!')
})

tap.ok(true)
tap.notOk(false)
tap.error(undefined)
tap.equal('foo', 'foo')
tap.not('foo', 'bar')
tap.same({ foo: 1 }, { foo: 1 })
tap.notSame({ foo: 1 }, { bar: 1 })
tap.strictSame([42], [42])
tap.strictNotSame([null], [undefined])
tap.match({ foo: 'bar' }, { foo: /^bar$/ })
tap.notMatch({ foo: 'bar' }, { foo: /baz/ })
tap.type(new Date(), Date)
tap.throws(function () {
  throw new Error('bang!')
})
tap.doesNotThrow(function () {})
github mcollina / fastify-secure-session / test / secret.js View on Github external
}, (error, response) => {
  t.error(error)
  t.equal(response.statusCode, 200)
  t.ok(response.headers['set-cookie'])

  fastify.inject({
    method: 'GET',
    url: '/',
    headers: {
      cookie: response.headers['set-cookie']
    }
  }, (error, response) => {
    t.error(error)
    t.deepEqual(JSON.parse(response.payload), { some: 'data' })
  })
})
github focusaurus / peterlyons.com / app / core / test-utils.js View on Github external
selectors.forEach(selector => {
    tap.ok($(selector).length > 0, `Document missing selector ${selector}`);
  });
}
github ibmruntimes / yieldable-json / test / test-stringify-intensity.js View on Github external
yj.stringifyAsync(obj, 0, 2, (err, str) => {
  if (!err) {
    tap.ok(flag >= 1, 'Async function was expected to yield at least' +
           ` once, but got ${flag}!`);
  } else
    tap.fail(err);
});