Repository: unexpectedjs/unexpected
Pull request #542 (2018-12-26 13:25:02)

Feature/unsupport to have items with function


Patch:
diff --git a/documentation/assertions/object/to-have-a-value-satisfying.md b/documentation/assertions/object/to-have-a-value-satisfying.md
index 555619c0..af3cb12c 100644
--- a/documentation/assertions/object/to-have-a-value-satisfying.md
+++ b/documentation/assertions/object/to-have-a-value-satisfying.md
@@ -1,5 +1,5 @@
 Asserts that an object contains at least one value that satisfies a given
-value, function or other assertion.
+value, function (wrapped in `expect.it`) or other assertion.
 
 Note that this assertion fails if passed an empty object as the subject.
 
@@ -13,9 +13,9 @@ expect(
 expect(
   { foo: 0, bar: 1, baz: 2, qux: 3 },
   'to have a value satisfying',
-  function(value, index) {
+  expect.it(function(value) {
     expect(value, 'to be a number');
-  }
+  })
 );
 
 expect(
diff --git a/documentation/assertions/object/to-have-keys-satisfying.md b/documentation/assertions/object/to-have-keys-satisfying.md
index 0df4fb08..5e6f89d9 100644
--- a/documentation/assertions/object/to-have-keys-satisfying.md
+++ b/documentation/assertions/object/to-have-keys-satisfying.md
@@ -6,11 +6,11 @@ Aliases: `to be a map whose keys satisfy`,
 `to be an object whose keys satisfy`, `to be a hash whose keys satisfy`.
 
 ```js
-expect({ foo: 0, bar: 1, baz: 2, qux: 3 }, 'to have keys satisfying', function(
+expect({ foo: 0, bar: 1, baz: 2, qux: 3 }, 'to have keys satisfying', expect.it(function(
   key
 ) {
   expect(key, 'to match', /^[a-z]{3}$/);
-});
+}));
 
 expect(
   { foo: 0, bar: 1, baz: 2, qux: 3 },
diff --git a/documentation/assertions/object/to-have-values-satisfying.md b/documentation/assertions/object/to-have-values-satisfying.md
index ab34cd47..e4048528 100644
--- a/documentation/assertions/object/to-have-values-satisfying.md
+++ b/documentation/assertions/object/to-have-values-satisfying.md
@@ -9,9 +9,9 @@ Aliases: `to be a map whose values satisfy`,
 expect(
   { foo: 0, bar: 1, baz: 2, qux: 3 },
   'to have values satisfying',
-  function(value, index) {
+  expect.it(function(value) {
     expect(value, 'to be a number');
-  }
+  })
 );
 
 expect(
diff --git a/lib/assertions.js b/lib/assertions.js
index c17eb1a3..1f265bc5 100644
--- a/lib/assertions.js
+++ b/lib/assertions.js
@@ -31,7 +31,11 @@ module.exports = expect => {
   );
 
   expect.addAssertion('<any> [not] to be <any>', (expect, subject, value) => {
-    expect(objectIs(subject, value), '[not] to be truthy');
+    if (objectIs(subject, value) === expect.flags.not) {
+      expect.fail({
+        label: 'should be'
+      });
+    }
   });
 
   expect.addAssertion(
@@ -1098,13 +1102,9 @@ module.exports = expect => {
 
       const keys = expect.subjectType.getKeys(subject);
       const expected = {};
-      keys.forEach((key, index) => {
+      keys.forEach(key => {
         if (typeof nextArg === 'string') {
           expected[key] = expect.it(s => expect.shift(s));
-        } else if (typeof nextArg === 'function') {
-          expected[key] = nextArg._expectIt
-            ? nextArg
-            : expect.it(s => nextArg(s, index));
         } else {
           expected[key] = nextArg;
         }
@@ -1203,12 +1203,10 @@ module.exports = expect => {
       expect.withError(
         () =>
           expect.promise[not ? 'all' : 'any'](
-            keys.map((key, index) => {
+            keys.map(key => {
               let expected;
               if (typeof nextArg === 'string') {
                 expected = expect.it(s => expect.shift(s));
-              } else if (typeof nextArg === 'function') {
-                expected = expect.it(s => nextArg(s, index));
               } else {
                 expected = nextArg;
               }
@@ -1460,7 +1458,7 @@ module.exports = expect => {
     '<function> to [exhaustively] satisfy <function>',
     (expect, subject, value) => {
       expect.errorMode = 'bubble';
-      expect(subject, 'to equal', value);
+      expect(subject, 'to be', value);
     }
   );
 
@@ -1967,7 +1965,9 @@ module.exports = expect => {
                         }
                         if (keyDiff && keyDiff.inline) {
                           valueOutput = keyDiff;
-                        } else if (typeof valueKey === 'function') {
+                        } else if (
+                          expect.findTypeOf(valueKey).is('expect.it')
+                        ) {
                           isInlineDiff = false;
                           annotation.appendErrorMessage(conflicting);
                         } else if (!keyDiff || (keyDiff && !keyDiff.inline)) {


Test patch:
diff --git a/test/assertions/to-have-a-value-satisfying.spec.js b/test/assertions/to-have-a-value-satisfying.spec.js
index c7dd2ec0..28e49013 100644
--- a/test/assertions/to-have-a-value-satisfying.spec.js
+++ b/test/assertions/to-have-a-value-satisfying.spec.js
@@ -71,9 +71,13 @@ describe('to have a value satisfying assertion', () => {
       'to be a number'
     );
 
-    expect({ foo: '0', bar: 1 }, 'to have a value satisfying', function(value) {
-      expect(value, 'to be a number');
-    });
+    expect(
+      { foo: '0', bar: 1 },
+      'to have a value satisfying',
+      expect.it(function(value) {
+        expect(value, 'to be a number');
+      })
+    );
 
     expect(
       { foo: 0, bar: 'bar' },
@@ -96,11 +100,13 @@ describe('to have a value satisfying assertion', () => {
       'to be a string'
     );
 
-    expect({ foo: '0', bar: '1' }, 'not to have a value satisfying', function(
-      value
-    ) {
-      expect(value, 'to be a number');
-    });
+    expect(
+      { foo: '0', bar: '1' },
+      'not to have a value satisfying',
+      expect.it(function(value) {
+        expect(value, 'to be a number');
+      })
+    );
 
     expect(
       { foo: 0, bar: 1 },
@@ -232,4 +238,22 @@ describe('to have a value satisfying assertion', () => {
       );
     });
   });
+
+  describe('when passed a function', function() {
+    function foo() {}
+
+    it('succeeds when object has that function as a value', function() {
+      expect({ abc: foo }, 'to have a value satisfying', foo);
+    });
+
+    it('fails when the array does not have that function as a value', function() {
+      expect(
+        function() {
+          expect({ abc: 123 }, 'to have a value satisfying', foo);
+        },
+        'to throw',
+        'expected { abc: 123 } to have a value satisfying function foo() {}'
+      );
+    });
+  });
 });
diff --git a/test/assertions/to-have-an-item-satisfying.spec.js b/test/assertions/to-have-an-item-satisfying.spec.js
index f4353f76..f7a1c746 100644
--- a/test/assertions/to-have-an-item-satisfying.spec.js
+++ b/test/assertions/to-have-an-item-satisfying.spec.js
@@ -44,9 +44,7 @@ describe('to have an item satisfying assertion', () => {
   it('asserts that at least one item in the array satisfies the RHS expectation', () => {
     expect(['foo', 1], 'to have an item satisfying', 'to be a number');
 
-    expect(['foo', 1], 'to have an item satisfying', function(item) {
-      expect(item, 'to be a number');
-    });
+    expect(['foo', 1], 'to have an item satisfying', 'to be a number');
 
     expect(
       [0, 1, 'foo', 2],
@@ -65,9 +63,13 @@ describe('to have an item satisfying assertion', () => {
   it('asserts that no items in the array satisfies the RHS expectation', () => {
     expect(['foo', 'bar'], 'not to have an item satisfying', 'to be a number');
 
-    expect(['foo', 'bar'], 'not to have an item satisfying', function(item) {
-      expect(item, 'to be a number');
-    });
+    expect(
+      ['foo', 'bar'],
+      'not to have an item satisfying',
+      expect.it(function(item) {
+        expect(item, 'to be a number');
+      })
+    );
 
     expect(
       [0, 1, 42, 2],
@@ -166,14 +168,6 @@ describe('to have an item satisfying assertion', () => {
     );
   });
 
-  it('provides the item index to the callback function', () => {
-    var arr = ['0', '1', '2', '3'];
-    expect(arr, 'to have an item satisfying', function(item, index) {
-      expect(index, 'to be a number');
-      expect(index, 'to be', parseInt(item, 10));
-    });
-  });
-
   describe('delegating to an async assertion', () => {
     var clonedExpect = expect
       .clone()
diff --git a/test/assertions/to-have-items-satisfying.spec.js b/test/assertions/to-have-items-satisfying.spec.js
index 624f31a7..722dd9b3 100644
--- a/test/assertions/to-have-items-satisfying.spec.js
+++ b/test/assertions/to-have-items-satisfying.spec.js
@@ -61,19 +61,22 @@ describe('to have items satisfying assertion', () => {
     );
   });
 
-  it('asserts that the given callback does not throw for any items in the array', () => {
-    expect([0, 1, 2, 3], 'to have items satisfying', function(item, index) {
-      expect(item, 'to be a number');
-      expect(index, 'to be a number');
-    });
+  it('asserts that the given expect.it-wrapped callback does not throw for any items in the array', () => {
+    expect(
+      [0, 1, 2, 3],
+      'to have items satisfying',
+      expect.it(function(item) {
+        expect(item, 'to be a number');
+      })
+    );
 
-    expect(['0', '1', '2', '3'], 'to have items satisfying', function(
-      item,
-      index
-    ) {
-      expect(item, 'not to be a number');
-      expect(index, 'to be a number');
-    });
+    expect(
+      ['0', '1', '2', '3'],
+      'to have items satisfying',
+      expect.it(function(item) {
+        expect(item, 'not to be a number');
+      })
+    );
 
     expect([0, 1, 2, 3], 'to have items satisfying', 'to be a number');
 
@@ -121,20 +124,20 @@ describe('to have items satisfying assertion', () => {
           ],
           'to have items satisfying',
           // prettier-ignore
-          function (item) {
+          expect.it(function (item) {
             expect.fail(function (output) {
               output.text('foo').nl().text('bar');
             });
-          }
+          })
         );
       },
       'to throw',
       'expected array to have items satisfying\n' +
-        'function (item) {\n' +
+        'expect.it(function (item) {\n' +
         '  expect.fail(function (output) {\n' +
         "    output.text('foo').nl().text('bar');\n" +
         '  });\n' +
-        '}\n' +
+        '})\n' +
         '\n' +
         '[\n' +
         '  [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ] // foo\n' +
@@ -151,20 +154,16 @@ describe('to have items satisfying assertion', () => {
     );
   });
 
-  it('provides the item index to the callback function', () => {
-    var arr = ['0', '1', '2', '3'];
-    expect(arr, 'to have items satisfying', function(item, index) {
-      expect(index, 'to be a number');
-      expect(index, 'to be', parseInt(item, 10));
-    });
-  });
-
   it('fails when the assertion fails', () => {
     expect(
       function() {
-        expect(['0', 1, '2', '3'], 'to have items satisfying', function(item) {
-          expect(item, 'not to be a number');
-        });
+        expect(
+          ['0', 1, '2', '3'],
+          'to have items satisfying',
+          expect.it(function(item) {
+            expect(item, 'not to be a number');
+          })
+        );
       },
       'to throw',
       /1, \/\/ should not be a number/
@@ -186,17 +185,21 @@ describe('to have items satisfying assertion', () => {
   it('provides a detailed report of where failures occur', () => {
     expect(
       function() {
-        expect([0, 1, '2', 3, 4], 'to have items satisfying', function(item) {
-          expect(item, 'to be a number');
-          expect(item, 'to be less than', 4);
-        });
+        expect(
+          [0, 1, '2', 3, 4],
+          'to have items satisfying',
+          expect.it(function(item) {
+            expect(item, 'to be a number');
+            expect(item, 'to be less than', 4);
+          })
+        );
       },
       'to throw',
       "expected [ 0, 1, '2', 3, 4 ] to have items satisfying\n" +
-        'function (item) {\n' +
+        'expect.it(function (item) {\n' +
         "  expect(item, 'to be a number');\n" +
         "  expect(item, 'to be less than', 4);\n" +
-        '}\n' +
+        '})\n' +
         '\n' +
         '[\n' +
         '  0,\n' +
@@ -215,20 +218,20 @@ describe('to have items satisfying assertion', () => {
           [[0, 1, 2], [4, '5', 6], [7, 8, '9']],
           'to have items satisfying',
           // prettier-ignore
-          function(arr) {
-            expect(arr, 'to have items satisfying', function (item) {
+          expect.it(function(arr) {
+            expect(arr, 'to have items satisfying', expect.it(function (item) {
               expect(item, 'to be a number');
-            });
-          }
+            }));
+          })
         );
       },
       'to throw',
       'expected array to have items satisfying\n' +
-        'function (arr) {\n' +
-        "  expect(arr, 'to have items satisfying', function (item) {\n" +
+        'expect.it(function (arr) {\n' +
+        "  expect(arr, 'to have items satisfying', expect.it(function (item) {\n" +
         "    expect(item, 'to be a number');\n" +
-        '  });\n' +
-        '}\n' +
+        '  }));\n' +
+        '})\n' +
         '\n' +
         '[\n' +
         '  [ 0, 1, 2 ],\n' +
@@ -332,15 +335,19 @@ describe('to have items satisfying assertion', () => {
   it('should not render a "not to match" diff inline', () => {
     expect(
       function() {
-        expect([']1V3ZRFOmgiE*'], 'to have items satisfying', function(item) {
-          expect(item, 'not to match', /[!@#$%^&*()_+]/);
-        });
+        expect(
+          [']1V3ZRFOmgiE*'],
+          'to have items satisfying',
+          expect.it(function(item) {
+            expect(item, 'not to match', /[!@#$%^&*()_+]/);
+          })
+        );
       },
       'to throw',
       "expected [ ']1V3ZRFOmgiE*' ] to have items satisfying\n" +
-        'function (item) {\n' +
+        'expect.it(function (item) {\n' +
         "  expect(item, 'not to match', /[!@#$%^&*()_+]/);\n" +
-        '}\n' +
+        '})\n' +
         '\n' +
         '[\n' +
         "  ']1V3ZRFOmgiE*' // should not match /[!@#$%^&*()_+]/\n" +
@@ -350,4 +357,27 @@ describe('to have items satisfying assertion', () => {
         ']'
     );
   });
+
+  describe('when passed a function', function() {
+    function foo() {}
+
+    it('succeeds when the subject is an array with only that function as items', function() {
+      expect([foo, foo], 'to have items satisfying', foo);
+    });
+
+    it('fails when the array contains other items', function() {
+      expect(
+        function() {
+          expect([123, 456], 'to have items satisfying', foo);
+        },
+        'to throw',
+        'expected [ 123, 456 ] to have items satisfying function foo() {}\n' +
+          '\n' +
+          '[\n' +
+          '  123, // should equal function foo() {}\n' +
+          '  456 // should equal function foo() {}\n' +
+          ']'
+      );
+    });
+  });
 });
diff --git a/test/assertions/to-have-keys-satisfying.spec.js b/test/assertions/to-have-keys-satisfying.spec.js
index c5e87e89..4302978b 100644
--- a/test/assertions/to-have-keys-satisfying.spec.js
+++ b/test/assertions/to-have-keys-satisfying.spec.js
@@ -33,33 +33,33 @@ describe('to have keys satisfying assertion', () => {
   it('only accepts objects as the target', () => {
     expect(
       function() {
-        expect(42, 'to have keys satisfying', function(key) {});
+        expect(42, 'to have keys satisfying', true);
       },
       'to throw',
-      'expected 42 to have keys satisfying function (key) {}\n' +
+      'expected 42 to have keys satisfying true\n' +
         '  The assertion does not have a matching signature for:\n' +
-        '    <number> to have keys satisfying <function>\n' +
+        '    <number> to have keys satisfying <boolean>\n' +
         '  did you mean:\n' +
         '    <object> to have keys satisfying <any>\n' +
         '    <object> to have keys satisfying <assertion>'
     );
   });
 
-  it('asserts that the given callback does not throw for any keys in the map', () => {
+  it('asserts that the given expect.it-wrapped callback does not throw for any keys in the map', () => {
     expect(
       { foo: 0, bar: 1, baz: 2, qux: 3 },
       'to have keys satisfying',
-      function(key) {
+      expect.it(function(key) {
         expect(key, 'not to be empty');
-      }
+      })
     );
 
     expect(
       { foo: 0, bar: 1, baz: 2, qux: 3 },
       'to have keys satisfying',
-      function(key) {
+      expect.it(function(key) {
         expect(key, 'to match', /^[a-z]{3}$/);
-      }
+      })
     );
 
     expect(
@@ -76,10 +76,14 @@ describe('to have keys satisfying assertion', () => {
     );
   });
 
-  it('receives the key and the value when the third argument is a function', () => {
-    expect({ foo: 123 }, 'to have keys satisfying', function(key) {
-      expect(key, 'to equal', 'foo');
-    });
+  it('receives the key when the third argument is an expect.it-wrapped function', () => {
+    expect(
+      { foo: 123 },
+      'to have keys satisfying',
+      expect.it(function(key) {
+        expect(key, 'to equal', 'foo');
+      })
+    );
   });
 
   it('fails if the given object is empty', () => {
@@ -124,17 +128,26 @@ describe('to have keys satisfying assertion', () => {
   });
 
   it('supports legacy aliases', () => {
-    expect({ foo: '0' }, 'to be a map whose keys satisfy', function(key) {
-      expect(key, 'to match', /^[a-z]{3}$/);
-    });
+    expect(
+      { foo: '0' },
+      'to be a map whose keys satisfy',
+      'to match',
+      /^[a-z]{3}$/
+    );
 
-    expect({ foo: '0' }, 'to be an object whose keys satisfy', function(key) {
-      expect(key, 'to match', /^[a-z]{3}$/);
-    });
+    expect(
+      { foo: '0' },
+      'to be an object whose keys satisfy',
+      'to match',
+      /^[a-z]{3}$/
+    );
 
-    expect({ foo: '0' }, 'to be a hash whose keys satisfy', function(key) {
-      expect(key, 'to match', /^[a-z]{3}$/);
-    });
+    expect(
+      { foo: '0' },
+      'to be a hash whose keys satisfy',
+      'to match',
+      /^[a-z]{3}$/
+    );
   });
 
   it('fails when the assertion fails', () => {
@@ -143,9 +156,8 @@ describe('to have keys satisfying assertion', () => {
         expect(
           { foo: 0, bar: 1, Baz: 2, qux: 3 },
           'to have keys satisfying',
-          function(key) {
-            expect(key, 'to match', /^[a-z]{3}$/);
-          }
+          'to match',
+          /^[a-z]{3}$/
         );
       },
       'to throw',
@@ -159,16 +171,16 @@ describe('to have keys satisfying assertion', () => {
         expect(
           { foo: 0, bar: 1, baz: 2, qux: 3, quux: 4 },
           'to have keys satisfying',
-          function(key) {
+          expect.it(function(key) {
             expect(key, 'to have length', 3);
-          }
+          })
         );
       },
       'to throw',
       'expected { foo: 0, bar: 1, baz: 2, qux: 3, quux: 4 } to have keys satisfying\n' +
-        'function (key) {\n' +
+        'expect.it(function (key) {\n' +
         "  expect(key, 'to have length', 3);\n" +
-        '}\n' +
+        '})\n' +
         '\n' +
         '[\n' +
         "  'foo',\n" +
diff --git a/test/assertions/to-have-values-satisfying.spec.js b/test/assertions/to-have-values-satisfying.spec.js
index d769035c..6622e658 100644
--- a/test/assertions/to-have-values-satisfying.spec.js
+++ b/test/assertions/to-have-values-satisfying.spec.js
@@ -33,12 +33,12 @@ describe('to have values satisfying assertion', () => {
   it('only accepts objects and arrays as the target', () => {
     expect(
       function() {
-        expect(42, 'to have values satisfying', function(value) {});
+        expect(42, 'to have values satisfying', expect.it(function(value) {}));
       },
       'to throw',
-      'expected 42 to have values satisfying function (value) {}\n' +
+      'expected 42 to have values satisfying expect.it(function (value) {})\n' +
         '  The assertion does not have a matching signature for:\n' +
-        '    <number> to have values satisfying <function>\n' +
+        '    <number> to have values satisfying <expect.it>\n' +
         '  did you mean:\n' +
         '    <object> to have values [exhaustively] satisfying <any>\n' +
         '    <object> to have values [exhaustively] satisfying <assertion>'
@@ -49,17 +49,17 @@ describe('to have values satisfying assertion', () => {
     expect(
       { foo: 0, bar: 1, baz: 2, qux: 3 },
       'to have values satisfying',
-      function(value) {
+      expect.it(function(value) {
         expect(value, 'to be a number');
-      }
+      })
     );
 
     expect(
       { foo: '0', bar: '1', baz: '2', qux: '3' },
       'to have values satisfying',
-      function(value) {
+      expect.it(function(value) {
         expect(value, 'not to be a number');
-      }
+      })
     );
 
     expect(
@@ -78,15 +78,19 @@ describe('to have values satisfying assertion', () => {
   it('fails if the given object is empty', () => {
     expect(
       function() {
-        expect({}, 'to have values satisfying', function(value) {
-          expect(value, 'to equal', '0');
-        });
+        expect(
+          {},
+          'to have values satisfying',
+          expect.it(function(value) {
+            expect(value, 'to equal', '0');
+          })
+        );
       },
       'to throw',
       'expected {} to have values satisfying\n' +
-        'function (value) {\n' +
+        'expect.it(function (value) {\n' +
         "  expect(value, 'to equal', '0');\n" +
-        '}\n' +
+        '})\n' +
         '  expected {} not to be empty'
     );
   });
@@ -119,19 +123,23 @@ describe('to have values satisfying assertion', () => {
   });
 
   it('supports legacy aliases', () => {
-    expect({ foo: '0' }, 'to be a map whose values satisfy', function(value) {
-      expect(value, 'not to be a number');
-    });
+    expect(
+      { foo: '0' },
+      'to be a map whose values satisfy',
+      'not to be a number'
+    );
 
-    expect({ foo: '0' }, 'to be an object whose values satisfy', function(
-      value
-    ) {
-      expect(value, 'not to be a number');
-    });
+    expect(
+      { foo: '0' },
+      'to be an object whose values satisfy',
+      'not to be a number'
+    );
 
-    expect({ foo: '0' }, 'to be a hash whose values satisfy', function(value) {
-      expect(value, 'not to be a number');
-    });
+    expect(
+      { foo: '0' },
+      'to be a hash whose values satisfy',
+      'not to be a number'
+    );
   });
 
   it('fails when the assertion fails', () => {
@@ -140,9 +148,9 @@ describe('to have values satisfying assertion', () => {
         expect(
           { foo: '0', bar: 1, baz: '2', qux: '3' },
           'to have values satisfying',
-          function(value) {
+          expect.it(function(value) {
             expect(value, 'not to be a number');
-          }
+          })
         );
       },
       'to throw',
@@ -156,18 +164,18 @@ describe('to have values satisfying assertion', () => {
         expect(
           { foo: 0, bar: 1, baz: '2', qux: 3, quux: 4 },
           'to have values satisfying',
-          function(value) {
+          expect.it(function(value) {
             expect(value, 'to be a number');
             expect(value, 'to be less than', 4);
-          }
+          })
         );
       },
       'to throw',
       'expected object to have values satisfying\n' +
-        'function (value) {\n' +
+        'expect.it(function (value) {\n' +
         "  expect(value, 'to be a number');\n" +
         "  expect(value, 'to be less than', 4);\n" +
-        '}\n' +
+        '})\n' +
         '\n' +
         '{\n' +
         '  foo: 0,\n' +
@@ -186,20 +194,20 @@ describe('to have values satisfying assertion', () => {
           { foo: [0, 1, 2], bar: [4, '5', 6], baz: [7, 8, '9'] },
           'to have values satisfying',
           // prettier-ignore
-          function (arr) {
-            expect(arr, 'to have items satisfying', function (item) {
+          expect.it(function (arr) {
+            expect(arr, 'to have items satisfying', expect.it(function (item) {
               expect(item, 'to be a number');
-            });
-          }
+            }));
+          })
         );
       },
       'to throw',
       'expected object to have values satisfying\n' +
-        'function (arr) {\n' +
-        "  expect(arr, 'to have items satisfying', function (item) {\n" +
+        'expect.it(function (arr) {\n' +
+        "  expect(arr, 'to have items satisfying', expect.it(function (item) {\n" +
         "    expect(item, 'to be a number');\n" +
-        '  });\n' +
-        '}\n' +
+        '  }));\n' +
+        '})\n' +
         '\n' +
         '{\n' +
         '  foo: [ 0, 1, 2 ],\n' +
@@ -298,4 +306,27 @@ describe('to have values satisfying assertion', () => {
       );
     });
   });
+
+  describe('when passed a function', function() {
+    function foo() {}
+
+    it('succeeds when the subject is an array with only that function as items', function() {
+      expect([foo, foo], 'to have values satisfying', foo);
+    });
+
+    it('fails when the array contains other items', function() {
+      expect(
+        function() {
+          expect([123, 456], 'to have values satisfying', foo);
+        },
+        'to throw',
+        'expected [ 123, 456 ] to have values satisfying function foo() {}\n' +
+          '\n' +
+          '[\n' +
+          '  123, // should equal function foo() {}\n' +
+          '  456 // should equal function foo() {}\n' +
+          ']'
+      );
+    });
+  });
 });
diff --git a/test/assertions/to-satisfy.spec.js b/test/assertions/to-satisfy.spec.js
index b325d096..33f4f906 100644
--- a/test/assertions/to-satisfy.spec.js
+++ b/test/assertions/to-satisfy.spec.js
@@ -2449,8 +2449,7 @@ describe('to satisfy assertion', () => {
         'to satisfy { foo: function myOtherFunction() {} }\n' +
         '\n' +
         '{\n' +
-        '  foo: function myFunction() {} // expected { foo: function myFunction() {} }\n' +
-        '                                // to satisfy { foo: function myOtherFunction() {} }\n' +
+        '  foo: function myFunction() {} // should be function myOtherFunction() {}\n' +
         '}'
     );
   });
@@ -2510,7 +2509,7 @@ describe('to satisfy assertion', () => {
             expect(foo, 'to satisfy', bar);
           },
           'to throw',
-          'expected function foo() {} to equal function bar() {}'
+          'expected function foo() {} to be function bar() {}'
         );
       });
     });