Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verify does not throw exception when too many arguments are passed #33

Closed
mweitzel opened this issue Oct 23, 2015 · 1 comment
Closed

Comments

@mweitzel
Copy link

Verify doesn't throw exceptions when too many arguments are passed. Right now its only on too few arguments or collisions.

I expected td.verify(double('any', 'parameters')) to default to checking arity, but currently only fails on too few arguments. Here's an example reproduction:

In a file td-repro.js

var td = require('testdouble')
  , test = require('tape')

test('verify tests arity matches', function(t) {
  t.plan(4)

  var stub0 = td.create()
  var stub1 = td.create()
  var stub2 = td.create()
  var stub3 = td.create()

  t.doesNotThrow(function() {
    stub0('any arguments', 0, 1, 2)
    td.verify(stub0())
  }, 'called with more arguments when none are specified')

  t.throws(function() {
    stub1(0)
    td.verify(stub2(0,0))
  }, 'called with fewer arguments fails')

  t.doesNotThrow(function() {
    stub2(0,0)
    td.verify(stub2(0,0))
  }, 'called with the same number succeeds')

  t.throws(function() {
    stub3(0,0,1)
    td.verify(stub3(0,0))
  }, 'called with more arguments fails') //   <-- does not fail
})

The command node td-repro.js gives this output:

TAP version 13
# verify tests arity matches
ok 1 called with more arguments when none are specified
ok 2 called with fewer arguments fails
ok 3 called with the same number succeeds
not ok 4 called with more arguments fails
  ---
    operator: throws
    expected: undefined
    actual:   undefined
    at: Test.<anonymous> (/Users/matthew/Projects/scrap/td-bug.js:27:5)
  ...

1..4
# tests 4
# pass  3
# fail  1
@searls
Copy link
Member

searls commented Oct 24, 2015

Landed in 0.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants