Skip to content

Commit

Permalink
chore: match on start of exception message (#350)
Browse files Browse the repository at this point in the history
Co-authored-by: Giorgi Kotchlamazashvili <[email protected]>
  • Loading branch information
hertzg and hertzg authored Dec 9, 2024
1 parent 04f29a2 commit 0bb654c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
22 changes: 11 additions & 11 deletions test/unit/test-interval.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,39 @@ describe('keep-alive interval', () => {

it('should validate passed arguments', function () {
;(() => Lib.setKeepAliveInterval()).should.throw(
'setKeepAliveInterval requires two arguments'
/^setKeepAliveInterval requires two arguments/
)
;(() => Lib.setKeepAliveInterval('')).should.throw(
'setKeepAliveInterval requires two arguments'
/^setKeepAliveInterval requires two arguments/
)
;(() => Lib.setKeepAliveInterval('', '', '')).should.throw(
'setKeepAliveInterval requires two arguments'
/^setKeepAliveInterval requires two arguments/
)
;(() => Lib.setKeepAliveInterval(null, 1)).should.throw(
'setKeepAliveInterval expects an instance of socket as its first argument'
/^setKeepAliveInterval expects an instance of socket as its first argument/
)
;(() => Lib.setKeepAliveInterval({}, 1)).should.throw(
'setKeepAliveInterval expects an instance of socket as its first argument'
/^setKeepAliveInterval expects an instance of socket as its first argument/
)
;(() => Lib.setKeepAliveInterval(new (class {})(), 1)).should.throw(
'setKeepAliveInterval expects an instance of socket as its first argument'
/^setKeepAliveInterval expects an instance of socket as its first argument/
)
;(() => Lib.setKeepAliveInterval(new Stream.PassThrough(), 1)).should.throw(
'setKeepAliveInterval expects an instance of socket as its first argument'
/^setKeepAliveInterval expects an instance of socket as its first argument/
)

const socket = new Net.Socket()
;(() => Lib.setKeepAliveInterval(socket, null)).should.throw(
'setKeepAliveInterval requires msec to be a Number'
/^setKeepAliveInterval requires msec to be a Number/
)
;(() => Lib.setKeepAliveInterval(socket, '')).should.throw(
'setKeepAliveInterval requires msec to be a Number'
/^setKeepAliveInterval requires msec to be a Number/
)
;(() => Lib.setKeepAliveInterval(socket, true)).should.throw(
'setKeepAliveInterval requires msec to be a Number'
/^setKeepAliveInterval requires msec to be a Number/
)
;(() => Lib.setKeepAliveInterval(socket, {})).should.throw(
'setKeepAliveInterval requires msec to be a Number'
/^setKeepAliveInterval requires msec to be a Number/
)
})

Expand Down
22 changes: 11 additions & 11 deletions test/unit/test-probes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,39 @@ describe('keep-alive probes', () => {

it('should validate passed arguments', function () {
;(() => Lib.setKeepAliveProbes()).should.throw(
'setKeepAliveProbes requires two arguments'
/^setKeepAliveProbes requires two arguments/
)
;(() => Lib.setKeepAliveProbes('')).should.throw(
'setKeepAliveProbes requires two arguments'
/^setKeepAliveProbes requires two arguments/
)
;(() => Lib.setKeepAliveProbes('', '', '')).should.throw(
'setKeepAliveProbes requires two arguments'
/^setKeepAliveProbes requires two arguments/
)
;(() => Lib.setKeepAliveProbes(null, 1)).should.throw(
'setKeepAliveProbes expects an instance of socket as its first argument'
/^setKeepAliveProbes expects an instance of socket as its first argument/
)
;(() => Lib.setKeepAliveProbes({}, 1)).should.throw(
'setKeepAliveProbes expects an instance of socket as its first argument'
/^setKeepAliveProbes expects an instance of socket as its first argument/
)
;(() => Lib.setKeepAliveProbes(new (class {})(), 1)).should.throw(
'setKeepAliveProbes expects an instance of socket as its first argument'
/^setKeepAliveProbes expects an instance of socket as its first argument/
)
;(() => Lib.setKeepAliveProbes(new Stream.PassThrough(), 1)).should.throw(
'setKeepAliveProbes expects an instance of socket as its first argument'
/^setKeepAliveProbes expects an instance of socket as its first argument/
)

const socket = new Net.Socket()
;(() => Lib.setKeepAliveProbes(socket, null)).should.throw(
'setKeepAliveProbes requires cnt to be a Number'
/^setKeepAliveProbes requires cnt to be a Number/
)
;(() => Lib.setKeepAliveProbes(socket, '')).should.throw(
'setKeepAliveProbes requires cnt to be a Number'
/^setKeepAliveProbes requires cnt to be a Number/
)
;(() => Lib.setKeepAliveProbes(socket, true)).should.throw(
'setKeepAliveProbes requires cnt to be a Number'
/^setKeepAliveProbes requires cnt to be a Number/
)
;(() => Lib.setKeepAliveProbes(socket, {})).should.throw(
'setKeepAliveProbes requires cnt to be a Number'
/^setKeepAliveProbes requires cnt to be a Number/
)
})

Expand Down
22 changes: 11 additions & 11 deletions test/unit/test-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,39 @@ describe('TCP User Timeout', () => {
itSkipOS(
['freebsd'],'should validate passed arguments', function () {
;(() => Lib.setUserTimeout()).should.throw(
'setUserTimeout requires two arguments'
/^setUserTimeout requires two arguments/
)
;(() => Lib.setUserTimeout('')).should.throw(
'setUserTimeout requires two arguments'
/^setUserTimeout requires two arguments/
)
;(() => Lib.setUserTimeout('', '', '')).should.throw(
'setUserTimeout requires two arguments'
/^setUserTimeout requires two arguments/
)
;(() => Lib.setUserTimeout(null, 1)).should.throw(
'setUserTimeout expects an instance of socket as its first argument'
/^setUserTimeout expects an instance of socket as its first argument/
)
;(() => Lib.setUserTimeout({}, 1)).should.throw(
'setUserTimeout expects an instance of socket as its first argument'
/^setUserTimeout expects an instance of socket as its first argument/
)
;(() => Lib.setUserTimeout(new (class {})(), 1)).should.throw(
'setUserTimeout expects an instance of socket as its first argument'
/^setUserTimeout expects an instance of socket as its first argument/
)
;(() => Lib.setUserTimeout(new Stream.PassThrough(), 1)).should.throw(
'setUserTimeout expects an instance of socket as its first argument'
/^setUserTimeout expects an instance of socket as its first argument/
)

const socket = new Net.Socket()
;(() => Lib.setUserTimeout(socket, null)).should.throw(
'setUserTimeout requires msec to be a Number'
/^setUserTimeout requires msec to be a Number/
)
;(() => Lib.setUserTimeout(socket, '')).should.throw(
'setUserTimeout requires msec to be a Number'
/^setUserTimeout requires msec to be a Number/
)
;(() => Lib.setUserTimeout(socket, true)).should.throw(
'setUserTimeout requires msec to be a Number'
/^setUserTimeout requires msec to be a Number/
)
;(() => Lib.setUserTimeout(socket, {})).should.throw(
'setUserTimeout requires msec to be a Number'
/^setUserTimeout requires msec to be a Number/
)
})

Expand Down

0 comments on commit 0bb654c

Please sign in to comment.