Skip to content

Commit 36bd379

Browse files
authored
Update parse.js
Fixing tests for the new sockets syntax.
1 parent 8daf384 commit 36bd379

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

test/parse.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,34 @@ describe('parse', () => {
3232
});
3333

3434
it('initializing with unix domain socket', () => {
35-
const subject1 = parse('?socket=' + encodeURIComponent('/const/run/'));
35+
const subject1 = parse('%2Fconst%2Frun%2F');
3636
subject1.host.should.equal('/const/run/');
3737
const subject2 = parse('test.domain.sock');
3838
subject2.host.should.equal('test.domain.sock');
3939
});
4040

4141
it('initializing with unix domain socket and a specific database, the simple way', () => {
42-
const subject = parse('/mydb?socket=' + encodeURIComponent('/const/run/'));
42+
const subject = parse('%2Fconst%2Frun%2F/mydb');
4343
subject.host.should.equal('/const/run/');
4444
subject.database.should.equal('mydb');
4545
});
4646

4747
it('initializing with unix domain socket, the healthy way', () => {
48-
const subject = parse('/my%5Bdb%5D?encoding=utf8&socket=' + encodeURIComponent('/some path/'));
48+
const subject = parse('%2Fsome%20path%2F/my%5Bdb%5D?encoding=utf8');
4949
subject.host.should.equal('/some path/');
50-
subject.database.should.equal('my[db]', 'must to be escaped and unescaped trough "my%5Bdb%5D"');
50+
subject.database.should.equal('my[db]', 'must be escaped and unescaped trough "my%5Bdb%5D"');
5151
subject.client_encoding.should.equal('utf8');
5252
});
5353

5454
it('initializing with unix domain socket, the escaped healthy way', () => {
55-
const subject = parse('/my%2Bdb?encoding=utf8&socket=' + encodeURIComponent('/some path/'));
55+
const subject = parse('%2Fsome%20path%2F/my%2Bdb?encoding=utf8');
5656
subject.host.should.equal('/some path/');
5757
subject.database.should.equal('my+db');
5858
subject.client_encoding.should.equal('utf8');
5959
});
6060

6161
it('initializing with unix domain socket, username and password', () => {
62-
const subject = parse('postgres://brian:pw@/mydb?socket=' + encodeURIComponent('/const/run/'));
62+
const subject = parse('postgres://brian:pw@%2Fconst%2Frun%2F/mydb');
6363
subject.user.should.equal('brian');
6464
subject.password.should.equal('pw');
6565
subject.host.should.equal('/const/run/');

0 commit comments

Comments
 (0)