Skip to content

Commit b747118

Browse files
committed
tests: add some timezone connection config tests
1 parent 66cca7b commit b747118

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

test/unit/test-ConnectionConfig.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ test('ConnectionConfig#Constructor', {
2727
},
2828

2929
'allows additional options via url query': function() {
30-
var url = 'mysql://myhost/mydb?debug=true&charset=BIG5_CHINESE_CI';
30+
var url = 'mysql://myhost/mydb?debug=true&charset=BIG5_CHINESE_CI&timezone=Z';
3131
var config = new ConnectionConfig(url);
3232

3333
assert.equal(config.host, 'myhost');
3434
assert.equal(config.port, 3306);
3535
assert.equal(config.database, 'mydb');
3636
assert.equal(config.debug, true);
3737
assert.equal(config.charsetNumber, common.Charsets.BIG5_CHINESE_CI);
38+
assert.equal(config.timezone, 'Z');
3839
},
3940

4041
'accepts client flags': function() {
@@ -179,6 +180,24 @@ test('ConnectionConfig#Constructor.ssl', {
179180
}
180181
});
181182

183+
test('ConnectionConfig#Constructor.timezone', {
184+
'defaults to "local"': function() {
185+
var config = new ConnectionConfig({});
186+
187+
assert.equal(config.timezone, 'local');
188+
},
189+
190+
'accepts url timezone with encoded +': function() {
191+
var config = new ConnectionConfig('mysql://myhost/mydb?timezone=%2b0200');
192+
assert.equal(config.timezone, '+0200');
193+
},
194+
195+
'accepts url timezone with literal +': function() {
196+
var config = new ConnectionConfig('mysql://myhost/mydb?timezone=+0200');
197+
assert.equal(config.timezone, '+0200');
198+
}
199+
});
200+
182201
test('ConnectionConfig#mergeFlags', {
183202
'adds flag to empty list': function() {
184203
var initial = '';

0 commit comments

Comments
 (0)