How to use the tap.test 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 jembi / hearth / test / server.js View on Github external
url: 'http://localhost:3447/fhir/Patient',
        headers: _.extend(
          env.getTestAuthHeaders(env.users.sysadminUser.email),
          {
            'content-type': 'application/json+fhir'
          }
        )
      }, (err, res) => {
        t.error(err)
        t.equals(res.statusCode, 200)
        done()
      })
    })
  })

  tap.test('server - should default to an openhim-style authentication when no config option is present', (t) => {
    config.setConf('authentication:type', undefined)

    // invalidate server file require so we can require a fresh copy of the server
    // file. This is needed because the auth mechanism is set as soon as the server
    // file is required.
    delete require.cache[require.resolve('../lib/server')]
    delete require.cache[require.resolve('../lib/fhir/core')]
    delete require.cache[require.resolve('../lib/fhir/hooks')]
    server = require('../lib/server')

    serverTestEnv(t, (db, done) => {
      request.get({
        url: 'http://localhost:3447/fhir/Patient',
        headers: _.extend(
          env.getTestAuthHeaders(env.users.sysadminUser.email),
          {
github focusaurus / peterlyons.com / app / work / layout-tap.js View on Github external
test.same(
    $("title").text(),
    "Peter Lyons: Cyber Lumberjack",
    "should have the normal title"
  );
  // should include the javascript with cachebusting
  testUtils.assertSelectors($, `script[src='/plws.js?v=${pack.version}']`);

  // should include HTML comment with app version
  testUtils.assertSelectors($, "meta[name=x-app-version]");
  test.same($("meta[name=x-app-version]").attr("content"), pack.version);

  test.end();
});

tap.test("should have the browserified JavaScript", test => {
  request(uri)
    .get(`/plws.js?v=${pack.version}`)
    .expect(200)
    .expect("Content-Type", "application/javascript; charset=utf-8")
    .expect("Content-Encoding", "gzip")
    .end(error => {
      test.error(error);
      test.end();
    });
});
github davidmarkclements / fast-redact / test / index.js View on Github external
})

test('parent wildcards – array – single index', ({ end, same }) => {
  const redact = fastRedact({ paths: ['insideArray.like[3].*.foo'], serialize: false })
  same(redact({ insideArray: { like: ['a', 'b', 'c', { this: { foo: 'meow' } }] } }), { insideArray: { like: ['a', 'b', 'c', { this: { foo: censor } }] } })
  end()
})

test('parent wildcards - handles null proto objects', ({ end, is }) => {
  const redact = fastRedact({ paths: ['a.*.c'], serialize: false })
  const result = redact({ __proto__: null, a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
  is(result.a.b.c, censor)
  end()
})

test('parent wildcards - handles paths that do not match object structure', ({ end, same }) => {
  const redact = fastRedact({ paths: ['a.*.y.z'], serialize: false })
  same(redact({ a: { b: { c: 's' } } }), { a: { b: { c: 's' } } })
  end()
})

test('parent wildcards - gracefully handles primitives that match intermediate keys in paths', ({ end, same }) => {
  const redact = fastRedact({ paths: ['a.*.c'], serialize: false })
  same(redact({ a: { b: null } }), { a: { b: null } })
  same(redact({ a: { b: 's' } }), { a: { b: 's' } })
  same(redact({ a: { b: 1 } }), { a: { b: 1 } })
  same(redact({ a: { b: undefined } }), { a: { b: undefined } })
  same(redact({ a: { b: true } }), { a: { b: true } })
  const sym = Symbol('sym')
  same(redact({ a: { b: sym } }), { a: { b: sym } })
  end()
})
github i18next / i18next-scanner / test / transform-stream.js View on Github external
lineEnding
            }
        };

        gulp.src('test/fixtures/modules/**/*.js')
            .pipe(scanner(options))
            .on('end', function() {
                t.end();
            })
            .pipe(tap(function(file) {
                const contents = file.contents.toString();
                t.ok(contents.endsWith(eol));
            }));
    });

    test('Line Feed (\\n)', function(t) {
        const eol = '\n';
        const lineEnding = '\n';
        const options = {
            ...defaults,
            resource: {
                ...defaults.resource,
                lineEnding
            }
        };

        gulp.src('test/fixtures/modules/**/*.js')
            .pipe(scanner(options))
            .on('end', function() {
                t.end();
            })
            .pipe(tap(function(file) {
github mikeal / rattan / test / test-basics.js View on Github external
test('basics: merge', async t => {
  t.plan(7)
  let db = getDatabase()
  let doc = await db.create('test1', doc => { doc.ok = true })
  let doc2 = await db.create('test2', doc => { doc.second = true })
  t.same(doc.ok, true)
  t.ok(!doc2.ok)
  t.same(doc2.second, true)
  t.ok(!doc.second)
  let merged = await db.merge('test1', await db.getDocument('test2'))
  t.same(merged.ok, true)
  t.same(merged.second, true)
  t.same(merged, await db.get('test1'))
})

test('basics: from', async t => {
  t.plan(1)
  let db = getDatabase()
  await db.create('test1', doc => { doc.ok = true })
  await db.from('test2', await db.getDocument('test1'))
  let history1 = await db.history('test1')
  let history2 = await db.history('test2')
  let _map = hist => hist.change
  t.same(history1.map(_map), history2.map(_map))
})

test('basics: edit w/ custom message', async t => {
  t.plan(3)
  let db = getDatabase()
  let doc = await db.create('test1', doc => { doc.ok = true })
  doc = await db.edit('test1', doc => { doc.ok = 'pass' }, 'test-message')
  t.same(doc.ok, 'pass')
github amio / micro-fork / test / index.spec.js View on Github external
})

tap.test('Response to GET:/ping with 200', t => {
  return request(server)
    .get('/ping')
    .expect(200, 'pong')
})

tap.test('Response to POST:/users with 200', t => {
  return request(server)
    .post('/users')
    .send({ name: 'john' })
    .expect(200, 'created')
})

tap.test('Response to DELETE:/users/123 with 200', t => {
  return request(server)
    .delete('/users/123')
    .expect(200, 'deleted 123')
})

tap.test('Response to GET:/users?age=20 with 200', t => {
  return request(server)
    .get('/users?age=20')
    .expect(200, 'query age 20')
})

tap.test('Response to unmatched route with 404', t => {
  return request(server)
    .get('/404')
    .expect(404)
})
github thlorenz / browserify-shim / test / shim / shim-depends.js View on Github external
'./lib/resolve-shims': resolveShims
  })

  browserify(entry, { fullPaths: fullPaths })
    .transform(shim)
    .bundle(function (err, src) {
      if (err) return cb(err);

      var ctx = { window: {}, console: console };
      ctx.self = ctx.window;
      var require_ = vm.runInNewContext(src, ctx);
      cb(null, require_)
    })
}

test('\nwhen I shim "jquery" and _ lib in debug mode and shim a lib that depends on both', function (t) {

  var entry = require.resolve('./fixtures/entry-requires-depend-on-jquery-and-_');
  runSecondBundle(entry, false, function (err, require_) {
    if (err) { t.fail(err); return t.end(); }

    var dep = require_(1);

    t.equal(dep.jqVersion, '1.8.3', 'when multidependent gets required, $ is attached to the window');
    t.equal(dep._(), 'super underscore', 'and _ is attached to the window');
    t.end()
  })
})

if (browserify_version >= 5)
test('\nwhen I shim "jquery" and _ lib in debug mode and shim a lib that depends on both, using fullPaths', function (t) {
github miketheprogrammer / node-ml / test / regression.js View on Github external
[6.5159,5.3436],
    [8.5172,4.2415],
    [9.1802,6.7981],
    [6.002,0.92695],
    [5.5204,0.152],
    [5.0594,2.8214],
    [5.7077,1.8451],
    [7.6366,4.2959],
    [5.8707,7.2029],
    [5.3054,1.9869],
    [8.2934,0.14454],
    [13.394,9.0551],
    [5.4369,0.61705]
];

test('Population by Profit Linear Regression', function(t) {
    var m = new LinearRegression(data);
    m.train(function(err, trainedModel) { 
        t.same(trainedModel.theta.cols(), 1);
        t.same(trainedModel.theta.rows(), 2);

        trainedModel.predict(6.1101, function(err, result) {
            t.same(result.out, 3.4962991573810798);
            trainedModel.predict(10, function(err, result) {
                t.same(result.out, 8.03333206395146);
                t.end();
            });
        });
    });
});
github mikeal / znode / test / test-basics.js View on Github external
}
})

test('arguments', async t => {
  t.plan(1)
  let rpc = {
    testargs: (one, two, three) => [one, two, three]
  }
  let server = createServer(rpc)
  await listen(server)(1234)
  let remote = await createClient(1234)
  t.same(await remote.testargs(1, 2, 3), [1, 2, 3])
  clear(server)
})

test('function without return', async t => {
  t.plan(2)
  let rpc = {
    test1: () => { },
    test2: async () => { }
  }
  let server = createServer(rpc)
  await listen(server)(1234)
  let remote = await createClient(1234)
  t.same(await remote.test1(), undefined)
  t.same(await remote.test2(), undefined)
  clear(server)
})
github orangewise / s3-zip / test / test-s3-same-file-alt-names.js View on Github external
})
  })
  return rs
}

var inputFiles = [
  '/fixtures/folder/a/file.txt',
  '/fixtures/folder/a/file.txt'
]
var outputFiles = [
  'FILE_1_ALT_1.TXT',
  'FILE_1_ALT_2.TXT'
]
var filesRead = []

t.test('test a tar archive with alternate names for one file listed many times', function (child) {
  var outputPath = join(__dirname, '/test-same_file_alt_name.tar')
  var output = fs.createWriteStream(outputPath)
  var archive = s3Zip
    .setFormat('tar')
    .archiveStream(fileStreamForFiles(inputFiles, true), inputFiles, outputFiles)
    .pipe(output)

  archive.on('close', function () {
    fs.createReadStream(outputPath)
      .pipe(tar.list())
      .on('entry', function (entry) {
        filesRead.push(entry.path)
      })
      .on('end', function () {
        child.same(filesRead, outputFiles)
        child.end()