Skip to content
This repository
Browse code

Dissimilarity test of null vs. an object must pass

  • Loading branch information...
commit 182d14427d2388bc9539cea85568f9702033587a 1 parent a62c7ab
Jason Smith jhs authored committed

Showing 2 changed files with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. +2 1  lib/tap-assert.js
  2. +3 2 test/meta-test.js
3  lib/tap-assert.js
@@ -239,7 +239,8 @@ function dissimilar (a, b, message, extra) {
239 239 if (extra && extra.skip) return assert.skip(message, extra)
240 240 // test that a has all the fields in b
241 241 message = message || "should be dissimilar"
242   - return inequivalent(selectFields(a, b), b, message, extra)
  242 + a = a && selectFields(a, b); // Always send selectFields() usable params.
  243 + return inequivalent(a, b, message, extra)
243 244 }
244 245 assert.dissimilar = dissimilar
245 246 syns.dissimilar = ["unsimilar"
5 test/meta-test.js
@@ -24,6 +24,7 @@ test("meta test", { skip: false }, function (t) {
24 24 t.doesNotThrow(noop, "noop does not throw");
25 25 t.similar({foo:"bar", bar:"foo"}, {foo:"bar"}, "similar objects are ok");
26 26 t.dissimilar({}, {mandatory:"value"}, "dissimilar objects are ok");
  27 + t.dissimilar(null, {}, "null is dissimilar from an object, even with no keys");
27 28
28 29 // a few failures.
29 30 t.ifError(new Error("this is an error"))
@@ -42,8 +43,8 @@ test("meta test", { skip: false }, function (t) {
42 43 t.clear()
43 44 t.ok(true, "sanity check")
44 45 t.notOk(results.ok, "not ok")
45   - t.equal(results.tests, 25, "total test count")
46   - t.equal(results.passTotal, 16, "tests passed")
  46 + t.equal(results.tests, 26, "total test count")
  47 + t.equal(results.passTotal, 17, "tests passed")
47 48 t.equal(results.fail, 9, "tests failed")
48 49 t.type(results.ok, "boolean", "ok is boolean")
49 50 t.type(results.skip, "number", "skip is number")

0 comments on commit 182d144

Please sign in to comment.
Something went wrong with that request. Please try again.