Skip to content

Commit

Permalink
Add function to satisfy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Dec 25, 2018
1 parent 08e574a commit 58be731
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/assertions/to-satisfy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2492,4 +2492,47 @@ describe('to satisfy assertion', () => {
'}'
);
});

describe('with a function subject', function() {
function foo() {}
function bar() {}
foo.baz = 123;

describe('against a function', function() {
it('should succeed', function() {
expect(foo, 'to satisfy', foo);
expect({ foo }, 'to satisfy', { foo });
});

it('should fail without a diff', function() {
expect(
function() {
expect(foo, 'to satisfy', bar);
},
'to throw',
'expected function foo() {} to equal function bar() {}'
);
});
});

describe('against an object', function() {
it('should succeed', function() {
expect(foo, 'to satisfy', { baz: 123 });
});

it('should fail with an object diff', function() {
expect(
function() {
expect(foo, 'to satisfy', { baz: 456 });
},
'to throw',
'expected function foo() {} to satisfy { baz: 456 }\n' +
'\n' +
'Function({\n' +
' baz: 123 // should equal 456\n' +
'})'
);
});
});
});
});

0 comments on commit 58be731

Please sign in to comment.