Skip to content

Commit

Permalink
adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Aug 13, 2020
1 parent 3b7f392 commit eedc222
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export function parseHost(host: string, direct?: boolean): IParsedHost | null {
}
if (h.name || h.port) {
Object.defineProperty(h, 'toString', {
value: (options: IEncodingOptions) => fullHostName(h, options)
value: (options: IEncodingOptions) => fullHostName(h, options),
enumerable: false
});
return h;
}
Expand Down
5 changes: 5 additions & 0 deletions test/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,11 @@ describe('parseHost', () => {
expect(parseHost('a.sock')).to.eql({name: 'a.sock', type: 'socket'});
expect(parseHost('/a')).to.eql({name: '/a', type: 'socket'});
expect(parseHost('a/')).to.eql({name: 'a/', type: 'socket'});

// TODO: host parsing is a bit buggy, needs overhaul
// odd/arguable tests:
// expect(parseHost('123.0.0.1-hello')).to.eql({name: '123.0.0.1-hello', type: 'IPv4'});
// expect(parseHost('[::]/here')).to.eql({name: '[::]here', type: 'IPv6'});
});
it('must use inside spaces', () => {
expect(parseHost(' a b ')).to.eql({name: 'a b', type: 'domain'});
Expand Down

0 comments on commit eedc222

Please sign in to comment.