From c37bde02f9fd0c2762e77b14cb2562b55721a512 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Sun, 29 Nov 2015 19:20:01 +0100 Subject: [PATCH] Update expected output. --- .../assertions/array/given-call-order.md | 16 +- .../array/to-have-calls-satisfying.md | 76 +++--- documentation/assertions/spy/threw.md | 10 +- .../spy/to-have-calls-satisfying.md | 42 ++-- documentation/assertions/spy/was-called-on.md | 18 +- .../assertions/spy/was-called-times.md | 10 +- .../assertions/spy/was-called-with.md | 60 ++--- documentation/assertions/spy/was-called.md | 4 +- .../assertions/spyCall/to-satisfy.md | 4 +- lib/unexpected-sinon.js | 15 +- test/documentation.spec.js | 236 ++++++++---------- test/unexpected-sinon.spec.js | 90 +++---- 12 files changed, 245 insertions(+), 336 deletions(-) diff --git a/documentation/assertions/array/given-call-order.md b/documentation/assertions/array/given-call-order.md index d3a3445..a21dc77 100644 --- a/documentation/assertions/array/given-call-order.md +++ b/documentation/assertions/array/given-call-order.md @@ -24,11 +24,9 @@ expect([obj.bar, obj.foo, obj.baz], 'given call order'); ```output expected [ bar, foo, baz ] given call order -[ - foo(); at theFunction (theFileName:xx:yy) // spy: expected foo to be bar - bar(); at theFunction (theFileName:xx:yy) // spy: expected bar to be foo - baz(); at theFunction (theFileName:xx:yy) -] +foo(); at theFunction (theFileName:xx:yy) // spy: expected foo to be bar +bar(); at theFunction (theFileName:xx:yy) // spy: expected bar to be foo +baz(); at theFunction (theFileName:xx:yy) ``` NOTE: This assertion has slightly different semantics from Sinon.js' own @@ -52,9 +50,7 @@ expect([spy1, spy2, spy2], 'given call order'); ```output expected [ spy1, spy2, spy2 ] given call order -[ - spy1(); at theFunction (theFileName:xx:yy) - spy2(); at theFunction (theFileName:xx:yy) - spy1(); at theFunction (theFileName:xx:yy) // spy: expected spy1 to be spy2 -] +spy1(); at theFunction (theFileName:xx:yy) +spy2(); at theFunction (theFileName:xx:yy) +spy1(); at theFunction (theFileName:xx:yy) // spy: expected spy1 to be spy2 ``` diff --git a/documentation/assertions/array/to-have-calls-satisfying.md b/documentation/assertions/array/to-have-calls-satisfying.md index 39b67b2..58aadcc 100644 --- a/documentation/assertions/array/to-have-calls-satisfying.md +++ b/documentation/assertions/array/to-have-calls-satisfying.md @@ -53,25 +53,23 @@ expected [ increment, noop ] to have calls satisfying } ] -[ - increment( - 456 // should equal 123 - ); at theFunction (theFileName:xx:yy) - noop( 987 ); at theFunction (theFileName:xx:yy) - increment( 123 ); at theFunction (theFileName:xx:yy) - // returned: expected 124 to equal 557 - noop( 555 ); at theFunction (theFileName:xx:yy) - increment( 666 ); at theFunction (theFileName:xx:yy) - // threw: expected Error('No, I won\'t do that') - // to satisfy { message: expect.it('not to match', /^No/) } - // - // { - // message: 'No, I won\'t do that' // should not match /^No/ - // // - // // No, I won't do that - // // ^^ - // } -] +increment( + 456 // should equal 123 +); at theFunction (theFileName:xx:yy) +noop( 987 ); at theFunction (theFileName:xx:yy) +increment( 123 ); at theFunction (theFileName:xx:yy) + // returned: expected 124 to equal 557 +noop( 555 ); at theFunction (theFileName:xx:yy) +increment( 666 ); at theFunction (theFileName:xx:yy) + // threw: expected Error('No, I won\'t do that') + // to satisfy { message: expect.it('not to match', /^No/) } + // + // { + // message: 'No, I won\'t do that' // should not match /^No/ + // // + // // No, I won't do that + // // ^^ + // } ``` Note that the individual arguments are matched with @@ -98,14 +96,12 @@ expect([ mySpy ], 'to have calls exhaustively satisfying', [ ```output expected [ mySpy ] to have calls exhaustively satisfying [ { args: [ ... ] } ] -[ - mySpy( - { - foo: 123, - bar: 456 // should be removed - } - ) at theFunction (theFileName:xx:yy) -] +mySpy( + { + foo: 123, + bar: 456 // should be removed + } +); at theFunction (theFileName:xx:yy) ``` You can also specify expected calls as a function that performs them: @@ -129,19 +125,15 @@ expect([ spy1, spy2 ], 'to have calls satisfying', function () { ```output expected [ spy1, spy2 ] to have calls satisfying -[ - spy1( 123 ); - spy2( 456 ); - spy1( expect.it('to be a string') ); - spy2( 789 ); -] - -[ - spy1( 123 ); at theFunction (theFileName:xx:yy) - spy2( 456 ); at theFunction (theFileName:xx:yy) - spy1( - false // should be a string - ); at theFunction (theFileName:xx:yy) - spy2( 789 ); at theFunction (theFileName:xx:yy) -] +spy1( 123 ); +spy2( 456 ); +spy1( expect.it('to be a string') ); +spy2( 789 ); + +spy1( 123 ); at theFunction (theFileName:xx:yy) +spy2( 456 ); at theFunction (theFileName:xx:yy) +spy1( + false // should be a string +); at theFunction (theFileName:xx:yy) +spy2( 789 ); at theFunction (theFileName:xx:yy) ``` diff --git a/documentation/assertions/spy/threw.md b/documentation/assertions/spy/threw.md index 6ca5c04..607ace6 100644 --- a/documentation/assertions/spy/threw.md +++ b/documentation/assertions/spy/threw.md @@ -49,10 +49,8 @@ expect(stub, 'always threw', /waat/); ```output expected myStub always threw /waat/ -[ - myStub(); at theFunction (theFileName:xx:yy) - // expected: threw /waat/ - // expected TypeError('wat') to satisfy /waat/ - myStub(); at theFunction (theFileName:xx:yy) -] +myStub(); at theFunction (theFileName:xx:yy) +// expected: threw /waat/ +// expected TypeError('wat') to satisfy /waat/ +myStub(); at theFunction (theFileName:xx:yy) ``` diff --git a/documentation/assertions/spy/to-have-calls-satisfying.md b/documentation/assertions/spy/to-have-calls-satisfying.md index b09ad75..12821b4 100644 --- a/documentation/assertions/spy/to-have-calls-satisfying.md +++ b/documentation/assertions/spy/to-have-calls-satisfying.md @@ -28,13 +28,11 @@ expect(increment, 'to have calls satisfying', [ ```output expected increment to have calls satisfying [ { args: [ 42 ] }, { args: [ 20 ] } ] -[ - increment( 42 ); at theFunction (theFileName:xx:yy) - increment( - 46, // should equal 20 - 'yadda' // should be removed - ); at theFunction (theFileName:xx:yy) -] +increment( 42 ); at theFunction (theFileName:xx:yy) +increment( + 46, // should equal 20 + 'yadda' // should be removed +); at theFunction (theFileName:xx:yy) ``` Note that the individual arguments are matched with @@ -61,14 +59,12 @@ expect(mySpy, 'to have calls exhaustively satisfying', [ ```output expected mySpy to have calls exhaustively satisfying [ { args: [ ... ] } ] -[ - mySpy( - { - foo: 123, - bar: 456 // should be removed - } - ) at theFunction (theFileName:xx:yy) -] +mySpy( + { + foo: 123, + bar: 456 // should be removed + } +); at theFunction (theFileName:xx:yy) ``` You can also specify expected calls as a function that performs them: @@ -87,14 +83,10 @@ expect(increment, 'to have calls satisfying', function () { ```output expected increment to have calls satisfying -[ - increment( 1 ); - increment( expect.it('to be a number') ); -] - -[ - increment( 1 ); at theFunction (theFileName:xx:yy) - increment( 2 ); at theFunction (theFileName:xx:yy) - increment( 3 ); at theFunction (theFileName:xx:yy) // should be removed -] +increment( 1 ); +increment( expect.it('to be a number') ); + +increment( 1 ); at theFunction (theFileName:xx:yy) +increment( 2 ); at theFunction (theFileName:xx:yy) +increment( 3 ); at theFunction (theFileName:xx:yy) // should be removed ``` diff --git a/documentation/assertions/spy/was-called-on.md b/documentation/assertions/spy/was-called-on.md index 266d609..a4a4e4c 100644 --- a/documentation/assertions/spy/was-called-on.md +++ b/documentation/assertions/spy/was-called-on.md @@ -16,11 +16,9 @@ expect(obj.spy, 'was called on', another); ```output expected mySpy was called on {} -[ - mySpy(); at theFunction (theFileName:xx:yy) - // expected: was called on {} - // expected mySpy to be called with {} as this but was called with { spy: mySpy } -] +mySpy(); at theFunction (theFileName:xx:yy) +// expected: was called on {} +// expected mySpy to be called with {} as this but was called with { spy: mySpy } ``` You can make this assertion more strict by using the `always` @@ -41,10 +39,8 @@ expect(obj.spy, 'was always called on', obj); ```output expected mySpy was always called on { spy: mySpy } -[ - mySpy(); at theFunction (theFileName:xx:yy) - mySpy(); at theFunction (theFileName:xx:yy) - // expected: was called on { spy: mySpy } - // expected mySpy to be called with { spy: mySpy } as this but was called with {} -] +mySpy(); at theFunction (theFileName:xx:yy) +mySpy(); at theFunction (theFileName:xx:yy) +// expected: was called on { spy: mySpy } +// expected mySpy to be called with { spy: mySpy } as this but was called with {} ``` diff --git a/documentation/assertions/spy/was-called-times.md b/documentation/assertions/spy/was-called-times.md index 209ab77..4e29718 100644 --- a/documentation/assertions/spy/was-called-times.md +++ b/documentation/assertions/spy/was-called-times.md @@ -22,12 +22,10 @@ expect(add, 'was called times', 2); ```output expected add was called times 2 expected - [ - add( 41, 42 ); at theFunction (theFileName:xx:yy) - add( 41, 43 ); at theFunction (theFileName:xx:yy) - add( 41, 44 ); at theFunction (theFileName:xx:yy) - add( 41, 45 ); at theFunction (theFileName:xx:yy) - ] + add( 41, 42 ); at theFunction (theFileName:xx:yy) + add( 41, 43 ); at theFunction (theFileName:xx:yy) + add( 41, 44 ); at theFunction (theFileName:xx:yy) + add( 41, 45 ); at theFunction (theFileName:xx:yy) to have length 2 expected 4 to be 2 ``` diff --git a/documentation/assertions/spy/was-called-with.md b/documentation/assertions/spy/was-called-with.md index ef09644..2311920 100644 --- a/documentation/assertions/spy/was-called-with.md +++ b/documentation/assertions/spy/was-called-with.md @@ -15,14 +15,12 @@ expect(mySpy, 'was called with', 'baz', { foo: 'bar' }); ```output expected mySpy was called with 'baz', { foo: 'bar' } -[ - mySpy( - { foo: 'bar' }, // should equal 'baz' - 'baz', // should equal { foo: 'bar' } - 'qux', - 'quux' - ); at theFunction (theFileName:xx:yy) -] +mySpy( + { foo: 'bar' }, // should equal 'baz' + 'baz', // should equal { foo: 'bar' } + 'qux', + 'quux' +); at theFunction (theFileName:xx:yy) ``` You can make this assertion more strict using the `always` flag. Then @@ -46,15 +44,13 @@ expect(mySpy, 'was always called with', { foo: 'bar' }, 'baz', expect.it('to be expected mySpy was always called with { foo: 'bar' }, 'baz', expect.it('to be truthy') -[ - mySpy( { foo: 'bar' }, 'baz', 'qux', 'quux' ); at theFunction (theFileName:xx:yy) - mySpy( { foo: 'bar' }, 'baz', 'qux', 'quux' ); at theFunction (theFileName:xx:yy) - mySpy( - { foo: 'bar' }, - 'baz' - // missing: should be truthy - ); at theFunction (theFileName:xx:yy) -] +mySpy( { foo: 'bar' }, 'baz', 'qux', 'quux' ); at theFunction (theFileName:xx:yy) +mySpy( { foo: 'bar' }, 'baz', 'qux', 'quux' ); at theFunction (theFileName:xx:yy) +mySpy( + { foo: 'bar' }, + 'baz' + // missing: should be truthy +); at theFunction (theFileName:xx:yy) ``` I case you want to ensure that the spy was called with the provided @@ -76,14 +72,12 @@ expect(mySpy, 'was called with exactly', { foo: 'bar' }, 'baz', expect.it('to be expected mySpy was called with exactly { foo: 'bar' }, 'baz', expect.it('to be truthy') -[ - mySpy( - { foo: 'bar' }, - 'baz', - 'qux', - 'quux' // should be removed - ); at theFunction (theFileName:xx:yy) -] +mySpy( + { foo: 'bar' }, + 'baz', + 'qux', + 'quux' // should be removed +); at theFunction (theFileName:xx:yy) ``` It is of course also possible to combine the two flags, that will then @@ -108,13 +102,11 @@ expect(mySpy, 'was always called with exactly', { foo: 'bar' }, 'baz', expect.it expected mySpy was always called with exactly { foo: 'bar' }, 'baz', expect.it('to be truthy') -[ - mySpy( { foo: 'bar' }, 'baz', 'qux' ); at theFunction (theFileName:xx:yy) - mySpy( { foo: 'bar' }, 'baz', 'qux' ); at theFunction (theFileName:xx:yy) - mySpy( - { foo: 'bar' }, - 'baz' - // missing: should be truthy - ); at theFunction (theFileName:xx:yy) -] +mySpy( { foo: 'bar' }, 'baz', 'qux' ); at theFunction (theFileName:xx:yy) +mySpy( { foo: 'bar' }, 'baz', 'qux' ); at theFunction (theFileName:xx:yy) +mySpy( + { foo: 'bar' }, + 'baz' + // missing: should be truthy +); at theFunction (theFileName:xx:yy) ``` diff --git a/documentation/assertions/spy/was-called.md b/documentation/assertions/spy/was-called.md index f20e5bc..4d72d36 100644 --- a/documentation/assertions/spy/was-called.md +++ b/documentation/assertions/spy/was-called.md @@ -33,7 +33,5 @@ expect(add, 'was not called'); ```output expected add was not called -[ - add( 42, 42 ); at theFunction (theFileName:xx:yy) // should be removed -] +add( 42, 42 ); at theFunction (theFileName:xx:yy) // should be removed ``` diff --git a/documentation/assertions/spyCall/to-satisfy.md b/documentation/assertions/spyCall/to-satisfy.md index e995816..9911491 100644 --- a/documentation/assertions/spyCall/to-satisfy.md +++ b/documentation/assertions/spyCall/to-satisfy.md @@ -26,12 +26,12 @@ expect(decrement.secondCall, 'to satisfy', { args: [ 20 ] }); ``` ```output -expected decrement( 200 ) at theFunction (theFileName:xx:yy) +expected decrement( 200 ); at theFunction (theFileName:xx:yy) to satisfy { args: [ 20 ] } decrement( 200 // should equal 20 -) at theFunction (theFileName:xx:yy) +); at theFunction (theFileName:xx:yy) ``` All the semantics of [to satisfy](http://unexpected.js.org/assertions/any/to-satisfy/) diff --git a/lib/unexpected-sinon.js b/lib/unexpected-sinon.js index 379808c..462d7a0 100644 --- a/lib/unexpected-sinon.js +++ b/lib/unexpected-sinon.js @@ -150,16 +150,15 @@ return baseType.similar(aItem, b.args[index]); }); }, + indent: false, + multipleLine: false, + leadingNewline: false, + trailingNewline: false, inspect: function (spyCalls, depth, output, inspect) { - this.prefix(output); - output.nl() - .indentLines() - .i().block(function (output) { + output + .block(function (output) { output.appendItems(spyCalls, '\n'); - }) - .nl() - .outdentLines(); - this.suffix(output); + }); } }); diff --git a/test/documentation.spec.js b/test/documentation.spec.js index 2010354..51c724a 100644 --- a/test/documentation.spec.js +++ b/test/documentation.spec.js @@ -42,11 +42,9 @@ describe("documentation tests", function () { expect(e, "to have message", "expected [ bar, foo, baz ] given call order\n" + "\n" + - "[\n" + - " foo(); at theFunction (theFileName:xx:yy) // spy: expected foo to be bar\n" + - " bar(); at theFunction (theFileName:xx:yy) // spy: expected bar to be foo\n" + - " baz(); at theFunction (theFileName:xx:yy)\n" + - "]" + "foo(); at theFunction (theFileName:xx:yy) // spy: expected foo to be bar\n" + + "bar(); at theFunction (theFileName:xx:yy) // spy: expected bar to be foo\n" + + "baz(); at theFunction (theFileName:xx:yy)" ); } @@ -73,11 +71,9 @@ describe("documentation tests", function () { expect(e, "to have message", "expected [ spy1, spy2, spy2 ] given call order\n" + "\n" + - "[\n" + - " spy1(); at theFunction (theFileName:xx:yy)\n" + - " spy2(); at theFunction (theFileName:xx:yy)\n" + - " spy1(); at theFunction (theFileName:xx:yy) // spy: expected spy1 to be spy2\n" + - "]" + "spy1(); at theFunction (theFileName:xx:yy)\n" + + "spy2(); at theFunction (theFileName:xx:yy)\n" + + "spy1(); at theFunction (theFileName:xx:yy) // spy: expected spy1 to be spy2" ); } return expect.promise.all(testPromises); @@ -144,25 +140,23 @@ describe("documentation tests", function () { " }\n" + "]\n" + "\n" + - "[\n" + - " increment(\n" + - " 456 // should equal 123\n" + - " ); at theFunction (theFileName:xx:yy)\n" + - " noop( 987 ); at theFunction (theFileName:xx:yy)\n" + - " increment( 123 ); at theFunction (theFileName:xx:yy)\n" + - " // returned: expected 124 to equal 557\n" + - " noop( 555 ); at theFunction (theFileName:xx:yy)\n" + - " increment( 666 ); at theFunction (theFileName:xx:yy)\n" + - " // threw: expected Error('No, I won\\'t do that')\n" + - " // to satisfy { message: expect.it('not to match', /^No/) }\n" + - " //\n" + - " // {\n" + - " // message: 'No, I won\\'t do that' // should not match /^No/\n" + - " // //\n" + - " // // No, I won't do that\n" + - " // // ^^\n" + - " // }\n" + - "]" + "increment(\n" + + " 456 // should equal 123\n" + + "); at theFunction (theFileName:xx:yy)\n" + + "noop( 987 ); at theFunction (theFileName:xx:yy)\n" + + "increment( 123 ); at theFunction (theFileName:xx:yy)\n" + + " // returned: expected 124 to equal 557\n" + + "noop( 555 ); at theFunction (theFileName:xx:yy)\n" + + "increment( 666 ); at theFunction (theFileName:xx:yy)\n" + + " // threw: expected Error('No, I won\\'t do that')\n" + + " // to satisfy { message: expect.it('not to match', /^No/) }\n" + + " //\n" + + " // {\n" + + " // message: 'No, I won\\'t do that' // should not match /^No/\n" + + " // //\n" + + " // // No, I won't do that\n" + + " // // ^^\n" + + " // }" ); } @@ -187,14 +181,12 @@ describe("documentation tests", function () { expect(e, "to have message", "expected [ mySpy ] to have calls exhaustively satisfying [ { args: [ ... ] } ]\n" + "\n" + - "[\n" + - " mySpy(\n" + - " {\n" + - " foo: 123,\n" + - " bar: 456 // should be removed\n" + - " }\n" + - " ) at theFunction (theFileName:xx:yy)\n" + - "]" + "mySpy(\n" + + " {\n" + + " foo: 123,\n" + + " bar: 456 // should be removed\n" + + " }\n" + + "); at theFunction (theFileName:xx:yy)" ); } @@ -234,21 +226,17 @@ describe("documentation tests", function () { } catch (e) { expect(e, "to have message", "expected [ spy1, spy2 ] to have calls satisfying\n" + - "[\n" + - " spy1( 123 );\n" + - " spy2( 456 );\n" + - " spy1( expect.it('to be a string') );\n" + - " spy2( 789 );\n" + - "]\n" + + "spy1( 123 );\n" + + "spy2( 456 );\n" + + "spy1( expect.it('to be a string') );\n" + + "spy2( 789 );\n" + "\n" + - "[\n" + - " spy1( 123 ); at theFunction (theFileName:xx:yy)\n" + - " spy2( 456 ); at theFunction (theFileName:xx:yy)\n" + - " spy1(\n" + - " false // should be a string\n" + - " ); at theFunction (theFileName:xx:yy)\n" + - " spy2( 789 ); at theFunction (theFileName:xx:yy)\n" + - "]" + "spy1( 123 ); at theFunction (theFileName:xx:yy)\n" + + "spy2( 456 ); at theFunction (theFileName:xx:yy)\n" + + "spy1(\n" + + " false // should be a string\n" + + "); at theFunction (theFileName:xx:yy)\n" + + "spy2( 789 ); at theFunction (theFileName:xx:yy)" ); } return expect.promise.all(testPromises); @@ -302,12 +290,10 @@ describe("documentation tests", function () { expect(e, "to have message", "expected myStub always threw /waat/\n" + "\n" + - "[\n" + - " myStub(); at theFunction (theFileName:xx:yy)\n" + - " // expected: threw /waat/\n" + - " // expected TypeError('wat') to satisfy /waat/\n" + - " myStub(); at theFunction (theFileName:xx:yy)\n" + - "]" + "myStub(); at theFunction (theFileName:xx:yy)\n" + + "// expected: threw /waat/\n" + + "// expected TypeError('wat') to satisfy /waat/\n" + + "myStub(); at theFunction (theFileName:xx:yy)" ); } return expect.promise.all(testPromises); @@ -350,13 +336,11 @@ describe("documentation tests", function () { expect(e, "to have message", "expected increment to have calls satisfying [ { args: [ 42 ] }, { args: [ 20 ] } ]\n" + "\n" + - "[\n" + - " increment( 42 ); at theFunction (theFileName:xx:yy)\n" + - " increment(\n" + - " 46, // should equal 20\n" + - " 'yadda' // should be removed\n" + - " ); at theFunction (theFileName:xx:yy)\n" + - "]" + "increment( 42 ); at theFunction (theFileName:xx:yy)\n" + + "increment(\n" + + " 46, // should equal 20\n" + + " 'yadda' // should be removed\n" + + "); at theFunction (theFileName:xx:yy)" ); } @@ -381,14 +365,12 @@ describe("documentation tests", function () { expect(e, "to have message", "expected mySpy to have calls exhaustively satisfying [ { args: [ ... ] } ]\n" + "\n" + - "[\n" + - " mySpy(\n" + - " {\n" + - " foo: 123,\n" + - " bar: 456 // should be removed\n" + - " }\n" + - " ) at theFunction (theFileName:xx:yy)\n" + - "]" + "mySpy(\n" + + " {\n" + + " foo: 123,\n" + + " bar: 456 // should be removed\n" + + " }\n" + + "); at theFunction (theFileName:xx:yy)" ); } @@ -418,16 +400,12 @@ describe("documentation tests", function () { } catch (e) { expect(e, "to have message", "expected increment to have calls satisfying\n" + - "[\n" + - " increment( 1 );\n" + - " increment( expect.it('to be a number') );\n" + - "]\n" + + "increment( 1 );\n" + + "increment( expect.it('to be a number') );\n" + "\n" + - "[\n" + - " increment( 1 ); at theFunction (theFileName:xx:yy)\n" + - " increment( 2 ); at theFunction (theFileName:xx:yy)\n" + - " increment( 3 ); at theFunction (theFileName:xx:yy) // should be removed\n" + - "]" + "increment( 1 ); at theFunction (theFileName:xx:yy)\n" + + "increment( 2 ); at theFunction (theFileName:xx:yy)\n" + + "increment( 3 ); at theFunction (theFileName:xx:yy) // should be removed" ); } return expect.promise.all(testPromises); @@ -452,11 +430,9 @@ describe("documentation tests", function () { expect(e, "to have message", "expected mySpy was called on {}\n" + "\n" + - "[\n" + - " mySpy(); at theFunction (theFileName:xx:yy)\n" + - " // expected: was called on {}\n" + - " // expected mySpy to be called with {} as this but was called with { spy: mySpy }\n" + - "]" + "mySpy(); at theFunction (theFileName:xx:yy)\n" + + "// expected: was called on {}\n" + + "// expected mySpy to be called with {} as this but was called with { spy: mySpy }" ); } @@ -475,12 +451,10 @@ describe("documentation tests", function () { expect(e, "to have message", "expected mySpy was always called on { spy: mySpy }\n" + "\n" + - "[\n" + - " mySpy(); at theFunction (theFileName:xx:yy)\n" + - " mySpy(); at theFunction (theFileName:xx:yy)\n" + - " // expected: was called on { spy: mySpy }\n" + - " // expected mySpy to be called with { spy: mySpy } as this but was called with {}\n" + - "]" + "mySpy(); at theFunction (theFileName:xx:yy)\n" + + "mySpy(); at theFunction (theFileName:xx:yy)\n" + + "// expected: was called on { spy: mySpy }\n" + + "// expected mySpy to be called with { spy: mySpy } as this but was called with {}" ); } return expect.promise.all(testPromises); @@ -515,12 +489,10 @@ describe("documentation tests", function () { expect(e, "to have message", "expected add was called times 2\n" + " expected\n" + - " [\n" + - " add( 41, 42 ); at theFunction (theFileName:xx:yy)\n" + - " add( 41, 43 ); at theFunction (theFileName:xx:yy)\n" + - " add( 41, 44 ); at theFunction (theFileName:xx:yy)\n" + - " add( 41, 45 ); at theFunction (theFileName:xx:yy)\n" + - " ]\n" + + " add( 41, 42 ); at theFunction (theFileName:xx:yy)\n" + + " add( 41, 43 ); at theFunction (theFileName:xx:yy)\n" + + " add( 41, 44 ); at theFunction (theFileName:xx:yy)\n" + + " add( 41, 45 ); at theFunction (theFileName:xx:yy)\n" + " to have length 2\n" + " expected 4 to be 2" ); @@ -553,14 +525,12 @@ describe("documentation tests", function () { expect(e, "to have message", "expected mySpy was called with 'baz', { foo: 'bar' }\n" + "\n" + - "[\n" + - " mySpy(\n" + - " { foo: 'bar' }, // should equal 'baz'\n" + - " 'baz', // should equal { foo: 'bar' }\n" + - " 'qux',\n" + - " 'quux'\n" + - " ); at theFunction (theFileName:xx:yy)\n" + - "]" + "mySpy(\n" + + " { foo: 'bar' }, // should equal 'baz'\n" + + " 'baz', // should equal { foo: 'bar' }\n" + + " 'qux',\n" + + " 'quux'\n" + + "); at theFunction (theFileName:xx:yy)" ); } @@ -583,15 +553,13 @@ describe("documentation tests", function () { "expected mySpy\n" + "was always called with { foo: 'bar' }, 'baz', expect.it('to be truthy')\n" + "\n" + - "[\n" + - " mySpy( { foo: 'bar' }, 'baz', 'qux', 'quux' ); at theFunction (theFileName:xx:yy)\n" + - " mySpy( { foo: 'bar' }, 'baz', 'qux', 'quux' ); at theFunction (theFileName:xx:yy)\n" + - " mySpy(\n" + - " { foo: 'bar' },\n" + - " 'baz'\n" + - " // missing: should be truthy\n" + - " ); at theFunction (theFileName:xx:yy)\n" + - "]" + "mySpy( { foo: 'bar' }, 'baz', 'qux', 'quux' ); at theFunction (theFileName:xx:yy)\n" + + "mySpy( { foo: 'bar' }, 'baz', 'qux', 'quux' ); at theFunction (theFileName:xx:yy)\n" + + "mySpy(\n" + + " { foo: 'bar' },\n" + + " 'baz'\n" + + " // missing: should be truthy\n" + + "); at theFunction (theFileName:xx:yy)" ); } @@ -611,14 +579,12 @@ describe("documentation tests", function () { "expected mySpy\n" + "was called with exactly { foo: 'bar' }, 'baz', expect.it('to be truthy')\n" + "\n" + - "[\n" + - " mySpy(\n" + - " { foo: 'bar' },\n" + - " 'baz',\n" + - " 'qux',\n" + - " 'quux' // should be removed\n" + - " ); at theFunction (theFileName:xx:yy)\n" + - "]" + "mySpy(\n" + + " { foo: 'bar' },\n" + + " 'baz',\n" + + " 'qux',\n" + + " 'quux' // should be removed\n" + + "); at theFunction (theFileName:xx:yy)" ); } @@ -641,15 +607,13 @@ describe("documentation tests", function () { "expected mySpy\n" + "was always called with exactly { foo: 'bar' }, 'baz', expect.it('to be truthy')\n" + "\n" + - "[\n" + - " mySpy( { foo: 'bar' }, 'baz', 'qux' ); at theFunction (theFileName:xx:yy)\n" + - " mySpy( { foo: 'bar' }, 'baz', 'qux' ); at theFunction (theFileName:xx:yy)\n" + - " mySpy(\n" + - " { foo: 'bar' },\n" + - " 'baz'\n" + - " // missing: should be truthy\n" + - " ); at theFunction (theFileName:xx:yy)\n" + - "]" + "mySpy( { foo: 'bar' }, 'baz', 'qux' ); at theFunction (theFileName:xx:yy)\n" + + "mySpy( { foo: 'bar' }, 'baz', 'qux' ); at theFunction (theFileName:xx:yy)\n" + + "mySpy(\n" + + " { foo: 'bar' },\n" + + " 'baz'\n" + + " // missing: should be truthy\n" + + "); at theFunction (theFileName:xx:yy)" ); } return expect.promise.all(testPromises); @@ -691,9 +655,7 @@ describe("documentation tests", function () { expect(e, "to have message", "expected add was not called\n" + "\n" + - "[\n" + - " add( 42, 42 ); at theFunction (theFileName:xx:yy) // should be removed\n" + - "]" + "add( 42, 42 ); at theFunction (theFileName:xx:yy) // should be removed" ); } return expect.promise.all(testPromises); @@ -735,12 +697,12 @@ describe("documentation tests", function () { }); } catch (e) { expect(e, "to have message", - "expected decrement( 200 ) at theFunction (theFileName:xx:yy)\n" + + "expected decrement( 200 ); at theFunction (theFileName:xx:yy)\n" + "to satisfy { args: [ 20 ] }\n" + "\n" + "decrement(\n" + " 200 // should equal 20\n" + - ") at theFunction (theFileName:xx:yy)" + "); at theFunction (theFileName:xx:yy)" ); } diff --git a/test/unexpected-sinon.spec.js b/test/unexpected-sinon.spec.js index b731071..956d255 100644 --- a/test/unexpected-sinon.spec.js +++ b/test/unexpected-sinon.spec.js @@ -83,9 +83,7 @@ describe('unexpected-sinon', function () { spy(); expect(spy, "was called twice"); }, "to throw exception", "expected spy1 was called twice\n" + - " expected\n" + - " spy1(); at theFunction (theFileName:xx:yy)\n" + - " to have length 2\n" + + " expected spy1(); at theFunction (theFileName:xx:yy) to have length 2\n" + " expected 1 to be 2" ); @@ -295,9 +293,11 @@ describe('unexpected-sinon', function () { }, 'to throw exception', "expected [ agent005, agent006, agent007 ] given call order\n" + "\n" + - "// missing { spy: agent005 }\n" + - "// missing { spy: agent006 }\n" + - "// missing { spy: agent007 }" + "[\n" + + " // missing { spy: agent005 }\n" + + " // missing { spy: agent006 }\n" + + " // missing { spy: agent007 }\n" + + "]" ); }); }); @@ -781,18 +781,16 @@ describe('unexpected-sinon', function () { }, 'to throw', "expected spy1 to have calls exhaustively satisfying [ { args: [ ..., ... ] } ]\n" + "\n" + - "[\n" + - " spy1(\n" + + "spy1(\n" + + " {\n" + + " foo: 123 // should be removed\n" + + " },\n" + + " [\n" + " {\n" + - " foo: 123 // should be removed\n" + - " },\n" + - " [\n" + - " {\n" + - " bar: 'quux' // should be removed\n" + - " }\n" + - " ]\n" + - " ) at theFunction (theFileName:xx:yy)\n" + - "]" + " bar: 'quux' // should be removed\n" + + " }\n" + + " ]\n" + + "); at theFunction (theFileName:xx:yy)" ); }); }); @@ -880,15 +878,11 @@ describe('unexpected-sinon', function () { }); }, 'to throw', "expected spy1 to have calls satisfying\n" + - "[\n" + - " spy1( 'def', false )\n" + - " spy1( 'abc', true )\n" + - "]\n" + + "spy1( 'def', false );\n" + + "spy1( 'abc', true );\n" + "\n" + - "[\n" + - " // missing spy1( 'def', false )\n" + - " spy1( 'abc', true ) at theFunction (theFileName:xx:yy)\n" + - "]" + "// missing spy1( 'def', false );\n" + + "spy1( 'abc', true ); at theFunction (theFileName:xx:yy)" ); }); @@ -906,19 +900,15 @@ describe('unexpected-sinon', function () { }); }, 'to throw', "expected spy1 to have calls satisfying\n" + - "[\n" + - " spy1( 123, 456 )\n" + - " spy1( false )\n" + - " spy1( 234 )\n" + - " spy1( 987 )\n" + - "]\n" + + "spy1( 123, 456 );\n" + + "spy1( false );\n" + + "spy1( 234 );\n" + + "spy1( 987 );\n" + "\n" + - "[\n" + - " spy1( 123, 456 ) at theFunction (theFileName:xx:yy)\n" + - " // missing spy1( false )\n" + - " spy1( 234 ) at theFunction (theFileName:xx:yy)\n" + - " spy1( 987 ) at theFunction (theFileName:xx:yy)\n" + - "]" + "spy1( 123, 456 ); at theFunction (theFileName:xx:yy)\n" + + "// missing spy1( false );\n" + + "spy1( 234 ); at theFunction (theFileName:xx:yy)\n" + + "spy1( 987 ); at theFunction (theFileName:xx:yy)" ); }); @@ -936,22 +926,18 @@ describe('unexpected-sinon', function () { }); }, 'to throw', "expected spy1 to have calls satisfying\n" + - "[\n" + - " spy1( 123, 456 )\n" + - " spy1( { foo: 456 } )\n" + - " spy1( 987 )\n" + - "]\n" + + "spy1( 123, 456 );\n" + + "spy1( { foo: 456 } );\n" + + "spy1( 987 );\n" + "\n" + - "[\n" + - " spy1( 123, 456 ) at theFunction (theFileName:xx:yy)\n" + - " spy1(\n" + - " {\n" + - " foo: 123 // should equal 456\n" + - " }\n" + - " ) at theFunction (theFileName:xx:yy)\n" + - " spy1( 456 ) at theFunction (theFileName:xx:yy) // should be removed\n" + - " spy1( 987 ) at theFunction (theFileName:xx:yy)\n" + - "]" + "spy1( 123, 456 ); at theFunction (theFileName:xx:yy)\n" + + "spy1(\n" + + " {\n" + + " foo: 123 // should equal 456\n" + + " }\n" + + "); at theFunction (theFileName:xx:yy)\n" + + "spy1( 456 ); at theFunction (theFileName:xx:yy) // should be removed\n" + + "spy1( 987 ); at theFunction (theFileName:xx:yy)" ); });