diff --git a/test/esm/unit/parsers/big-numbers-strings-binary-sanitization.test.mjs b/test/esm/unit/parsers/big-numbers-strings-binary-sanitization.test.mjs new file mode 100644 index 0000000000..5f1b990e7f --- /dev/null +++ b/test/esm/unit/parsers/big-numbers-strings-binary-sanitization.test.mjs @@ -0,0 +1,66 @@ +import { describe, test, assert } from 'poku'; +import { createConnection, describeOptions } from '../../../common.test.cjs'; + +const connection = createConnection().promise(); + +const sql = 'SELECT 9007199254740991+100 AS `total`'; + +describe('Binary Parser: bigNumberStrings Sanitization', describeOptions); + +Promise.all([ + test(async () => { + const [results] = await connection.execute({ + sql, + supportBigNumbers: true, + bigNumberStrings: true, + }); + + assert.strictEqual( + typeof results[0].total, + 'string', + 'Valid bigNumberStrings enabled', + ); + }), + test(async () => { + const [results] = await connection.execute({ + sql, + supportBigNumbers: false, + bigNumberStrings: false, + }); + + assert.strictEqual( + typeof results[0].total, + 'number', + 'Valid bigNumberStrings disabled', + ); + }), + + test(async () => { + const [results] = await connection.execute({ + sql, + supportBigNumbers: 'text', + bigNumberStrings: 'text', + }); + + assert.strictEqual( + typeof results[0].total, + 'string', + 'bigNumberStrings as a random string should be enabled', + ); + }), + test(async () => { + const [results] = await connection.execute({ + sql, + supportBigNumbers: '', + bigNumberStrings: '', + }); + + assert.strictEqual( + typeof results[0].total, + 'number', + 'bigNumberStrings as an empty string should be disabled', + ); + }), +]).then(async () => { + await connection.end(); +}); diff --git a/test/esm/unit/parsers/big-numbers-strings-sanitization.test.mjs b/test/esm/unit/parsers/big-numbers-strings-text-sanitization.test.mjs similarity index 95% rename from test/esm/unit/parsers/big-numbers-strings-sanitization.test.mjs rename to test/esm/unit/parsers/big-numbers-strings-text-sanitization.test.mjs index 09cc6a2d81..3d8a842da3 100644 --- a/test/esm/unit/parsers/big-numbers-strings-sanitization.test.mjs +++ b/test/esm/unit/parsers/big-numbers-strings-text-sanitization.test.mjs @@ -5,7 +5,7 @@ const connection = createConnection().promise(); const sql = 'SELECT 9007199254740991+100 AS `total`'; -describe('bigNumberStrings Sanitization', describeOptions); +describe('Text Parser: bigNumberStrings Sanitization', describeOptions); Promise.all([ test(async () => { diff --git a/test/unit/parsers/cache-key-serialization.test.cjs b/test/esm/unit/parsers/cache-key-serialization.test.mjs similarity index 98% rename from test/unit/parsers/cache-key-serialization.test.cjs rename to test/esm/unit/parsers/cache-key-serialization.test.mjs index 841850e933..3744110b18 100644 --- a/test/unit/parsers/cache-key-serialization.test.cjs +++ b/test/esm/unit/parsers/cache-key-serialization.test.mjs @@ -1,8 +1,5 @@ -'use strict'; - -const { assert } = require('poku'); -const _keyFromFields = - require('../../../lib/parsers/parser_cache.js')._keyFromFields; +import { assert } from 'poku'; +import { _keyFromFields } from '../../../../lib/parsers/parser_cache.js'; // Invalid const test1 = { diff --git a/test/esm/unit/parsers/support-big-numbers-binary-sanitization.test.mjs b/test/esm/unit/parsers/support-big-numbers-binary-sanitization.test.mjs new file mode 100644 index 0000000000..156cbfd1b1 --- /dev/null +++ b/test/esm/unit/parsers/support-big-numbers-binary-sanitization.test.mjs @@ -0,0 +1,62 @@ +import { describe, test, assert } from 'poku'; +import { createConnection, describeOptions } from '../../../common.test.cjs'; + +const connection = createConnection().promise(); + +const sql = 'SELECT 9007199254740991+100 AS `total`'; + +describe('Binary Parser: supportBigNumbers Sanitization', describeOptions); + +Promise.all([ + test(async () => { + const [results] = await connection.execute({ + sql, + supportBigNumbers: true, + }); + + assert.strictEqual( + typeof results[0].total, + 'string', + 'Valid supportBigNumbers enabled', + ); + }), + test(async () => { + const [results] = await connection.execute({ + sql, + supportBigNumbers: false, + }); + + assert.strictEqual( + typeof results[0].total, + 'number', + 'Valid supportBigNumbers disabled', + ); + }), + + test(async () => { + const [results] = await connection.execute({ + sql, + supportBigNumbers: 'text', + }); + + assert.strictEqual( + typeof results[0].total, + 'string', + 'supportBigNumbers as a random string should be enabled', + ); + }), + test(async () => { + const [results] = await connection.execute({ + sql, + supportBigNumbers: '', + }); + + assert.strictEqual( + typeof results[0].total, + 'number', + 'supportBigNumbers as an empty string should be disabled', + ); + }), +]).then(async () => { + await connection.end(); +}); diff --git a/test/esm/unit/parsers/support-big-numbers-sanitization.test.mjs b/test/esm/unit/parsers/support-big-numbers-text-sanitization.test.mjs similarity index 94% rename from test/esm/unit/parsers/support-big-numbers-sanitization.test.mjs rename to test/esm/unit/parsers/support-big-numbers-text-sanitization.test.mjs index 174ed76ffa..da5b6a6203 100644 --- a/test/esm/unit/parsers/support-big-numbers-sanitization.test.mjs +++ b/test/esm/unit/parsers/support-big-numbers-text-sanitization.test.mjs @@ -5,7 +5,7 @@ const connection = createConnection().promise(); const sql = 'SELECT 9007199254740991+100 AS `total`'; -describe('supportBigNumbers Sanitization', describeOptions); +describe('Text Parser: supportBigNumbers Sanitization', describeOptions); Promise.all([ test(async () => {