Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fastify.listen(0, err => {
t.error(err)
fastify.server.unref()
test('https get request', async (t) => {
t.plan(3)
const url = `https://localhost:${fastify.server.address().port}`
const res = await h2url.concat({ url })
t.strictEqual(res.headers[':status'], 200)
t.strictEqual(res.headers['content-length'], '' + JSON.stringify(msg).length)
t.deepEqual(JSON.parse(res.body), msg)
})
})
instance.listen(0, (err) => {
t.error(err)
get(`http://localhost:${instance.server.address().port}`, (err, res, data) => {
t.error(err)
t.strictEqual(res.statusCode, 200)
t.strictEqual(res.headers['content-type'], 'application/json')
t.strictEqual(typeof JSON.parse(data).origin, 'string')
})
})
jstp.net.reconnect(connection, port, (error, conn) => {
test.error(error, 'must reconnect without errors');
connection = conn;
});
});
connection.callMethodWithResend('iface', 'method', [], error => {
test.error(error, 'callMethodWithResend must not encounter an error');
test.pass('callback must be called');
connection.close();
server.close();
});
});
connection.callMethod('iface', 'first', [TOKEN], error => {
test.error(error, 'call to iface.first must not return an error');
connection.close();
connection.once('close', () => {
setTimeout(() => {
reconnect(connection, port);
}, TIMEOUT * 10);
});
});
}
}, (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' })
})
})
jstp.net.connect(appName, client, port, (error, conn, session) => {
test.error(error, 'must connect without errors');
connection = conn;
client.session = session;
callback();
});
}
}, function (err, res) {
t.error(err)
t.equal(res.statusCode, 200)
t.deepEqual(JSON.parse(res.payload), { exports: 'default' })
})
target.listen(0, (err) => {
t.error(err)
get(`http://localhost:${instance.server.address().port}`, (err, res, data) => {
t.error(err)
t.equal(res.headers['content-type'], 'text/plain')
t.equal(res.headers['x-another-header'], 'so headers!')
t.notOk(res.headers['x-my-header'])
t.equal(res.statusCode, 205)
})
})
})
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 () {})