diff --git a/.taprc b/.taprc index b052dba..cfa7780 100644 --- a/.taprc +++ b/.taprc @@ -1,5 +1,4 @@ jobs: 1 jsx: false -esm: false ts: false flow: false diff --git a/package.json b/package.json index d2e2c3d..2fd0095 100644 --- a/package.json +++ b/package.json @@ -1,43 +1,43 @@ -{ - "name": "fastify-mysql", - "version": "2.1.0", - "description": "Fastify Mysql connection plugin", - "main": "index.js", - "types": "index.d.ts", - "scripts": { - "mariadb": "docker run -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --rm mariadb:10.1", - "mysql": "npm run mysql:8.0", - "mysql:5.7": "docker run -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --rm mysql:5.7", - "mysql:5.5": "docker run -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --rm mysql:5.5", - "mysql:8.0": "docker run -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --rm mysql:8.0", - "test": "standard && tap test/*.test.js && npm run typescript", - "typescript": "tsd" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/fastify/fastify-mysql.git" - }, - "keywords": [ - "fastify", - "mysql", - "database", - "connection", - "sql" - ], - "license": "MIT", - "bugs": { - "url": "https://github.com/fastify/fastify-mysql/issues" - }, - "homepage": "https://github.com/fastify/fastify-mysql#readme", - "dependencies": { - "fastify-plugin": "^3.0.0", - "mysql2": "^2.0.0" - }, - "devDependencies": { - "@types/node": "^14.14.21", - "fastify": "^3.0.0", - "standard": "^16.0.0", - "tap": "^14.10.7", - "tsd": "^0.14.0" - } -} +{ + "name": "fastify-mysql", + "version": "2.1.0", + "description": "Fastify Mysql connection plugin", + "main": "index.js", + "types": "index.d.ts", + "scripts": { + "mariadb": "docker run -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --rm mariadb:10.1", + "mysql": "npm run mysql:8.0", + "mysql:5.7": "docker run -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --rm mysql:5.7", + "mysql:5.5": "docker run -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --rm mysql:5.5", + "mysql:8.0": "docker run -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --rm mysql:8.0", + "test": "standard && tap test/*.test.js && npm run typescript", + "typescript": "tsd" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/fastify/fastify-mysql.git" + }, + "keywords": [ + "fastify", + "mysql", + "database", + "connection", + "sql" + ], + "license": "MIT", + "bugs": { + "url": "https://github.com/fastify/fastify-mysql/issues" + }, + "homepage": "https://github.com/fastify/fastify-mysql#readme", + "dependencies": { + "fastify-plugin": "^3.0.0", + "mysql2": "^2.0.0" + }, + "devDependencies": { + "@types/node": "^14.14.21", + "fastify": "^3.0.0", + "standard": "^16.0.0", + "tap": "^15.0.1", + "tsd": "^0.14.0" + } +} \ No newline at end of file diff --git a/test/connection.test.js b/test/connection.test.js index cb0abd2..b7f4dd2 100644 --- a/test/connection.test.js +++ b/test/connection.test.js @@ -33,21 +33,18 @@ test('fastify.mysql namespace should exist', (t) => { test('utils should work', (t) => { let fastify = null - t.beforeEach((done) => { + t.beforeEach(() => { fastify = Fastify() fastify.register(fastifyMysql, { type: 'connection', connectionString: 'mysql://root@localhost/mysql' }) - - done() }) - t.afterEach((done) => { + t.afterEach(() => { fastify.close() fastify = null - done() }) t.test('query util', (t) => { @@ -83,7 +80,7 @@ test('utils should work', (t) => { t.error(err) const sqlString = fastify.mysql.format('SELECT ? AS `now`', [1]) - t.is('SELECT 1 AS `now`', sqlString) + t.equal('SELECT 1 AS `now`', sqlString) t.end() }) }) @@ -94,7 +91,7 @@ test('utils should work', (t) => { const id = 'userId' const sql = 'SELECT * FROM users WHERE id = ' + fastify.mysql.escape(id) - t.is(sql, `SELECT * FROM users WHERE id = '${id}'`) + t.equal(sql, `SELECT * FROM users WHERE id = '${id}'`) t.end() }) }) @@ -115,7 +112,7 @@ test('utils should work', (t) => { test('promise connection', (t) => { let fastify = null - t.beforeEach((done) => { + t.beforeEach(() => { fastify = Fastify() fastify.register(fastifyMysql, { @@ -123,12 +120,10 @@ test('promise connection', (t) => { type: 'connection', connectionString: 'mysql://root@localhost/mysql' }) - done() }) - t.afterEach((done) => { + t.afterEach(() => { fastify.close() fastify = null - done() }) t.test('query util', (t) => { @@ -162,7 +157,7 @@ test('promise connection', (t) => { t.error(err) const sqlString = fastify.mysql.format('SELECT ? AS `now`', [1]) - t.is('SELECT 1 AS `now`', sqlString) + t.equal('SELECT 1 AS `now`', sqlString) t.end() }) }) @@ -173,7 +168,7 @@ test('promise connection', (t) => { const id = 'userId' const sql = 'SELECT * FROM users WHERE id = ' + fastify.mysql.escape(id) - t.is(sql, `SELECT * FROM users WHERE id = '${id}'`) + t.equal(sql, `SELECT * FROM users WHERE id = '${id}'`) t.end() }) }) @@ -225,7 +220,7 @@ test('Promise: should throw when mysql2 fail to perform operation', (t) => { fastify.mysql.test.connection.query(sql).catch((errors) => { t.ok(errors) - t.is(errors.message, "Table 'mysql.fastify' doesn't exist") + t.equal(errors.message, "Table 'mysql.fastify' doesn't exist") }) }) }) diff --git a/test/initialization.test.js b/test/initialization.test.js index 593b980..02550e5 100644 --- a/test/initialization.test.js +++ b/test/initialization.test.js @@ -54,7 +54,7 @@ test('Should throw when trying to register multiple instances without giving a n fastify.ready((errors) => { t.ok(errors) - t.is(errors.message, 'fastify-mysql has already been registered') + t.equal(errors.message, 'fastify-mysql has already been registered') }) }) @@ -77,7 +77,7 @@ test('Should throw with duplicate connection names', (t) => { fastify.ready((errors) => { t.ok(errors) - t.is(errors.message, `fastify-mysql '${name}' instance name has already been registered`) + t.equal(errors.message, `fastify-mysql '${name}' instance name has already been registered`) }) }) @@ -98,7 +98,7 @@ test('Should throw when mysql2 fail', (t) => { fastify.ready((errors) => { t.ok(errors) - t.is(errors.message, `connect ECONNREFUSED ${HOST}:${BAD_PORT}`) + t.equal(errors.message, `connect ECONNREFUSED ${HOST}:${BAD_PORT}`) }) }) @@ -120,7 +120,7 @@ test('Promise: Should throw when mysql2 fail', (t) => { fastify.ready((errors) => { t.ok(errors) - t.is(errors.message, `connect ECONNREFUSED ${HOST}:${BAD_PORT}`) + t.equal(errors.message, `connect ECONNREFUSED ${HOST}:${BAD_PORT}`) }) }) @@ -143,7 +143,7 @@ test('Connection - Promise: Should throw when mysql2 fail', (t) => { fastify.ready((errors) => { t.ok(errors) - t.is(errors.message, `connect ECONNREFUSED ${HOST}:${BAD_PORT}`) + t.equal(errors.message, `connect ECONNREFUSED ${HOST}:${BAD_PORT}`) t.pass() }) }) @@ -164,7 +164,7 @@ test('Promise - Should throw when trying to register multiple instances without fastify.ready((errors) => { t.ok(errors) - t.is(errors.message, 'fastify-mysql has already been registered') + t.equal(errors.message, 'fastify-mysql has already been registered') t.pass() }) }) @@ -188,7 +188,7 @@ test('Promise - Should throw with duplicate connection names', (t) => { fastify.ready((errors) => { t.ok(errors) - t.is(errors.message, `fastify-mysql '${name}' instance name has already been registered`) + t.equal(errors.message, `fastify-mysql '${name}' instance name has already been registered`) t.pass() }) }) diff --git a/test/pool.promise.test.js b/test/pool.promise.test.js index d726f0c..1364ae1 100644 --- a/test/pool.promise.test.js +++ b/test/pool.promise.test.js @@ -7,7 +7,7 @@ const fastifyMysql = require('../index') test('promise pool', (t) => { let fastify - t.beforeEach((done) => { + t.beforeEach(() => { fastify = Fastify() fastify.register(fastifyMysql, { promise: true, @@ -16,12 +16,10 @@ test('promise pool', (t) => { database: 'mysql', connectionLimit: 1 }) - done() }) - t.afterEach((done) => { + t.afterEach(() => { fastify.close() - done() }) t.test('mysql.pool.query', (t) => { diff --git a/test/pool.test.js b/test/pool.test.js index e400ba5..51af15b 100644 --- a/test/pool.test.js +++ b/test/pool.test.js @@ -146,14 +146,14 @@ test('synchronous functions', (t) => { test('mysql.format', (t) => { const sqlString = fastify.mysql.format('SELECT ? AS `now`', [1]) - t.is('SELECT 1 AS `now`', sqlString) + t.equal('SELECT 1 AS `now`', sqlString) t.end() }) test('mysql.escape', (t) => { const id = 'userId' const sql = 'SELECT * FROM users WHERE id = ' + fastify.mysql.escape(id) - t.is(sql, `SELECT * FROM users WHERE id = '${id}'`) + t.equal(sql, `SELECT * FROM users WHERE id = '${id}'`) t.end() })