-
-
Notifications
You must be signed in to change notification settings - Fork 625
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74abf9e
commit 71115d8
Showing
5 changed files
with
132 additions
and
7 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
test/esm/unit/parsers/big-numbers-strings-binary-sanitization.test.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 2 additions & 5 deletions
7
.../parsers/cache-key-serialization.test.cjs → .../parsers/cache-key-serialization.test.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
test/esm/unit/parsers/support-big-numbers-binary-sanitization.test.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters