Skip to content

Commit 489e840

Browse files
dresendedougwilson
authored andcommitted
tests: add tests for mysql.format() function
1 parent 9be6991 commit 489e840

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/unit/test-Mysql.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var assert = require('assert');
2+
var common = require('../common');
3+
var path = require('path');
4+
var test = require('utest');
5+
var Mysql = require(path.resolve(common.lib, '../index'));
6+
7+
test('Mysql.format', {
8+
'format SQL with identifiers and values': function() {
9+
assert.equal(
10+
Mysql.format('SELECT * FROM ?? WHERE ?? = ?', ['table', 'property', 123]),
11+
'SELECT * FROM `table` WHERE `property` = 123'
12+
);
13+
},
14+
15+
'format SQL with object value': function() {
16+
assert.equal(
17+
Mysql.format('INSERT INTO ?? SET ?', ['table', {property: 123}]),
18+
'INSERT INTO `table` SET `property` = 123'
19+
);
20+
}
21+
});

0 commit comments

Comments
 (0)