How to use the tap.equal 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 isaacs / minizlib / test / deflate-constructors.js View on Github external
'use strict'

const zlib = require('../')
const t = require('tap')

// Throws if `opts.chunkSize` is invalid
t.throws(_ => new zlib.Deflate({chunkSize: -Infinity}))

// Confirm that maximum chunk size cannot be exceeded because it is `Infinity`.
t.equal(zlib.constants.Z_MAX_CHUNK, Infinity)

// Throws if `opts.windowBits` is invalid
t.throws(_ => new zlib.Deflate({windowBits: -Infinity, chunkSize: 12345}))
t.throws(_ => new zlib.Deflate({windowBits: Infinity}))

// Throws if `opts.level` is invalid
t.throws(_ => new zlib.Deflate({level: -Infinity}))
t.throws(_ => new zlib.Deflate({level: Infinity}))

// Throws a RangeError if `level` invalid in  `Deflate.prototype.params()`
t.throws(_ => new zlib.Deflate().params(-Infinity))
t.throws(_ => new zlib.Deflate().params(Infinity))

// Throws if `opts.memLevel` is invalid
t.throws(_ => new zlib.Deflate({memLevel: -Infinity}))
t.throws(_ => new zlib.Deflate({memLevel: Infinity}))
github dmester / jdenticon / test / node / sha1.js View on Github external
"use strict";

var tap = require("tap");
var sha1 = require("../../src/common/sha1");

tap.equal("92cfceb39d57d914ed8b14d0e37643de0797ae56", sha1(42));
tap.equal("21d90aad4d34f48f4aad9b5fa3c37c118af16df9", sha1("Value to be hashed"));
tap.equal("d5d4cd07616a542891b7ec2d0257b3a24b69856e", sha1()); // undefined
tap.equal("2be88ca4242c76e8253ac62474851065032d6833", sha1(null));
tap.equal("08a73daac75982601504c4ba956f49e73ee52667", sha1("abcåäö")); // non-ASCII chars
tap.equal("da39a3ee5e6b4b0d3255bfef95601890afd80709", sha1(""));
tap.equal("11f6ad8ec52a2984abaafd7c3b516503785c2072", sha1("x"));

// The message is broken down to 64 byte blocks. Test the region around 64 bytes.

// 54 chars
tap.equal("6d9fbf872b4e22afee77d8c9e95c10ec03bc731d", sha1("012345678901234567890123456789012345678901234567890123"));

// 55 chars
tap.equal("9f3a4ce7f66b1b74c34da2c5d732c39f81e0f8df", sha1("0123456789012345678901234567890123456789012345678901234"));

// 56 chars
github isaacs / yallist / test / basic.js View on Github external
var t = require('tap')
var Yallist = require('../yallist.js')

var y = new Yallist(1, 2, 3, 4, 5)
var z = new Yallist([1, 2, 3, 4, 5])
t.similar(y, z, 'build from single list or args')

function add10 (i) {
  return i + 10
}
t.similar(y.map(add10).toArray(), [11, 12, 13, 14, 15])
t.similar(y.mapReverse(add10).toArray(), [15, 14, 13, 12, 11])

t.similar(y.map(add10).toArrayReverse(), [15, 14, 13, 12, 11])
t.isa(Yallist(1, 2, 3), 'Yallist')
t.equal(y.push(6, 7, 8), 8)
t.similar(y.toArray(), [1, 2, 3, 4, 5, 6, 7, 8])
y.pop()
y.shift()
y.unshift(100)

var expect = [100, 2, 3, 4, 5, 6, 7]
var expectReverse = [ 7, 6, 5, 4, 3, 2, 100 ]

t.similar(y.toArray(), expect)
t.equal(y.length, y.toArray().length)

t.test(function forEach (t) {
  t.plan(y.length * 2)
  y.forEach(function (item, i, list) {
    t.equal(item, expect[i])
    t.equal(list, y)
github npm / arborist / test / link.js View on Github external
t.same(l1.children.size, 0, 'children still empty after being sasigned')
l1.children.set('asdf', 'foo')
t.same(l1.children.size, 0, 'children still empty after setting value')

t.throws(() => new Link({ path: '/x' }), {
  message: 'must provide realpath for Link node',
})

const resolver = new Link({
  path: '/x/y/z',
  realpath: '/x/z/y/a/b/c',
})
t.equal(resolver.resolved,
  'file:../../z/y/a/b/c', 'link resolved is relpath to realpath')
resolver.path = null
t.equal(resolver.resolved, null, 'link resolved depends on path')
resolver.path = '/x/z/y/a/b/d'
t.equal(resolver.resolved, 'file:../c', 'updates when path changes')

t.matchSnapshot(new Link({
  path: '/home/user/some/other/path',
  target: root,
}), 'instantiate with target specified')

t.test('link.target setter', t => {
  const link = new Link({
    path: '/path/to/link',
    realpath: '/node-a',
    pkg: { name: 'node-a', version: '1.2.3' },
  })
  const oldTarget = link.target
  t.equal(oldTarget.linksIn.has(link), true, 'target takes note of link')
github prantlf / nettime / tests / nettime.js View on Github external
function checkRequest (options, result) {
  let resultCount = 4
  test.equal(typeof result, 'object')
  if (options.returnResponse) {
    ++resultCount
  }
  if (options.includeHeaders) {
    ++resultCount
  }
  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 isaacs / minipass / test / is-stream.js View on Github external
t.equal(MP.isStream(new MP), true, 'a MiniPass is a stream')
t.equal(MP.isStream(new Stream), true, 'a Stream is a stream')
t.equal((new MP) instanceof Stream, true, 'a MiniPass is a Stream')
const w = new EE()
w.write = () => {}
w.end = () => {}
t.equal(MP.isStream(w), true, 'EE with write() and end() is a stream')
const r = new EE()
r.pipe = () => {}
t.equal(MP.isStream(r), true, 'EE with pipe() is a stream')
t.equal(MP.isStream(new Stream.Readable()), true, 'Stream.Readable() is a stream')
t.equal(MP.isStream(new Stream.Writable()), true, 'Stream.Writable() is a stream')
t.equal(MP.isStream(new Stream.Duplex()), true, 'Stream.Duplex() is a stream')
t.equal(MP.isStream(new Stream.Transform()), true, 'Stream.Transform() is a stream')
t.equal(MP.isStream(new Stream.PassThrough()), true, 'Stream.PassThrough() is a stream')
t.equal(MP.isStream(new (class extends MP {})), true, 'extends MP is a stream')
t.equal(MP.isStream(new EE), false, 'EE without streaminess is not a stream')
t.equal(MP.isStream({
  write(){},
  end(){},
  pipe(){},
}), false, 'non-EE is not a stream')
t.equal(MP.isStream('hello'), false, 'string is not a stream')
t.equal(MP.isStream(99), false, 'number is not a stream')
t.equal(MP.isStream(() => {}), false, 'function is not a stream')
t.equal(MP.isStream(null), false, 'null is not a stream')
github fastify / fastify-autoload / test / basic.js View on Github external
}, function (err, res) {
    t.error(err)
    t.equal(res.statusCode, 200)
    t.deepEqual(JSON.parse(res.payload), { overide: 'prefix' })
  })
github submarineswaps / swaps-service / test / swaps / test_swap_details.js View on Github external
const details = swapScriptDetails({
  network: 'regtest',
  script: fixtures.swap_redeem_script,
});

equal(details.destination_public_key, '03a81f284d64682c6dcb96a1cadd46a9102cacc3a8664b156a13fd79fcae8afb06');
equal(details.p2sh_address, '2N6LsbohZzyaz4QjssfxnbwZLPJMGRSxbBt');
equal(details.p2sh_output_script, 'a9148fab1cbefac11b8aad3813ca34b9d72dcad8187687');
equal(details.p2sh_p2wsh_address, '2NE5HHz4FFV1ecrsJ7qF3gfJtA61HuGDKDX');
equal(details.p2sh_p2wsh_output_script, 'a914e4793da9954fff2f74e5796ee1974b26da44a3c587');
equal(details.p2wsh_address, 'tb1qgwlqvyp89cwqmswtamep57uvmujhcxj5k02wfzr5zefph4y7h0nqq5340t');
equal(details.payment_hash, 'd0c3a2c094bbc9301549f0af85f6bd2330b9ab25');
equal(details.refund_p2wpkh_address, 'tb1q3330vzxyl7hcgrl77gyf5035e2u9mawc5p8825');
equal(details.refund_public_key_hash, '8c62f608c4ffaf840ffef2089a3e34cab85df5d8');
equal(details.timelock_block_height, 632);
equal(details.witness_output_script, '002043be0610272e1c0dc1cbeef21a7b8cdf257c1a54b3d4e4887416521bd49ebbe6');
github YahooArchive / mendel / test / require-transform.js View on Github external
'var baz = require(\'some/dir/variation2/baz\');',
    'var qux = require(\'some/dir/base/qux\');',
].join('\n');

var mendelifiedModules = ['bar', 'baz', 'qux'];
var out = requireTransform('./', src, variationDirs, false);

mendelifiedModules.forEach(function(mod) {
    t.match(out, '__mendel_require__(\'' + mod + '\')', 'mendelified require');
    t.notMatch(out, 'require(\'' + mod + '\')', 'node require');
});

t.match(out, 'require(\'foo\')', 'node require');
t.notMatch(out, '__mendel_require__(\'foo\')', 'mendelified require');

t.equal(out.indexOf(wrapper[0]), -1, 'wrapper prelude not present');
t.equal(out.indexOf(wrapper[1]), -1, 'wrapper epilogue not present');

out = requireTransform('./', src, variationDirs, true);
t.equal(out.indexOf(wrapper[0]), 0, 'wrapper prelude pos');
t.equal(out.indexOf(wrapper[1]), out.length - wrapper[1].length, 'wrapper epilogue pos');
github fastify / fastify-autoload / test / dependency.js View on Github external
}, function (err, res) {
    t.error(err)
    t.equal(res.statusCode, 200)
    t.deepEqual(JSON.parse(res.payload), { data: 'plugin-d' })
  })