From 65b158bf46a36881f9756c08d46764911dfaff74 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Sun, 11 Feb 2018 21:12:25 -0500 Subject: [PATCH] Update dependencies --- package.json | 6 ++--- plugin.js | 5 +++- test/tests.test.js | 58 +++++++++++++++++++++++++--------------------- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index f6eb694..e36c1e1 100644 --- a/package.json +++ b/package.json @@ -27,14 +27,14 @@ }, "homepage": "https://github.com/fastify/fastify-url-data#readme", "devDependencies": { - "fastify": "^0.30.3", + "fastify": "^1.0.0-rc.1", "pre-commit": "^1.2.2", "snazzy": "^7.0.0", "standard": "^10.0.3", - "tap": "^10.7.2" + "tap": "^11.1.0" }, "dependencies": { - "fastify-plugin": "^0.1.1", + "fastify-plugin": "^0.2.2", "uri-js": "^3.0.2" } } diff --git a/plugin.js b/plugin.js index 287413d..d63eaeb 100644 --- a/plugin.js +++ b/plugin.js @@ -12,4 +12,7 @@ function plugin (fastify, options, next) { next() } -module.exports = fp(plugin, '>=0.15.0') +module.exports = fp(plugin, { + fastify: '>=1.0.0-rc.1', + name: 'fastify-url-data' +}) diff --git a/test/tests.test.js b/test/tests.test.js index c280085..9de1276 100644 --- a/test/tests.test.js +++ b/test/tests.test.js @@ -1,39 +1,43 @@ 'use strict' const http = require('http') -const tap = require('tap') -const test = tap.test -const fastify = require('fastify')() +const test = require('tap').test +const Fastify = require('fastify') const plugin = require('../') -fastify.register(plugin, (err) => { - if (err) tap.error(err) -}) - -fastify.listen(0, (err) => { - if (err) tap.error(err) - fastify.server.unref() +test('parses a full URI', (t) => { + t.plan(8) + let port + const fastify = Fastify() - const port = fastify.server.address().port + fastify + .register(plugin) + .after((err) => { + if (err) t.error(err) + }) - test('parses a full URI', (t) => { - t.plan(8) + fastify.get('/one', (req, reply) => { + const uriData = req.urlData() + t.is(uriData.host, '127.0.0.1') + t.is(uriData.port, port) + t.is(uriData.path, '/one') + t.is(uriData.query, 'a=b&c=d') + t.is(req.urlData('host'), '127.0.0.1') + t.is(req.urlData('port'), port) + t.is(req.urlData('path'), '/one') + t.is(req.urlData('query'), 'a=b&c=d') + reply.send() + }) - fastify.get('/one', (req, reply) => { - const uriData = req.urlData() - t.is(uriData.host, '127.0.0.1') - t.is(uriData.port, port) - t.is(uriData.path, '/one') - t.is(uriData.query, 'a=b&c=d') - t.is(req.urlData('host'), '127.0.0.1') - t.is(req.urlData('port'), port) - t.is(req.urlData('path'), '/one') - t.is(req.urlData('query'), 'a=b&c=d') - reply.send() - }) + fastify.listen(0, (err) => { + fastify.server.unref() + if (err) t.threw(err) + port = fastify.server.address().port http - .get(`http://127.0.0.1:${port}/one?a=b&c=d#foo`, (res) => {}) - .on('error', t.threw) + .get(`http://127.0.0.1:${port}/one?a=b&c=d#foo`, (res) => {}) + .on('error', t.threw) }) + + t.tearDown(() => fastify.close()) })