/*global expect*/
describe('fail assertion', function () {
    it('throws an error', function () {
        expect(function () {
            expect.fail();
        }, 'to throw exception', "Explicit failure");
    });

    it('sets the error message', function () {
        var wasCaught = false;
        try {
            expect.fail('fail with error message');
        } catch (e) {
            wasCaught = true;
            expect(e.message, 'to contain', 'fail with error message');
        }
        expect(wasCaught, 'to be true');
    });

    it('throws an error with a given message', function () {
        expect(function () {
            expect.fail('fail with error message');
        }, 'to throw exception', "fail with error message");
    });

    it('supports placeholders', function () {
        expect(function () {
            expect.fail('{0} was expected to be {1}', 0, 'zero');
        }, 'to throw exception', "0 was expected to be 'zero'");

        expect(function () {
            var output = expect.output.clone().text('zero');
            expect.fail('{0} was expected to be {1}', 0, output);
        }, 'to throw exception', "0 was expected to be zero");

        expect(function () {
            expect.fail('{0} was expected to be {1}', 0);
        }, 'to throw exception', "0 was expected to be {1}");
    });

    describe('with an object', function () {
        it('should support specifying a label', function () {
            expect(function () {
                expect.fail({
                    label: 'to yadda'
                });
            }, 'to throw', {
                label: 'to yadda'
            });
        });

        it('should set additional properties on the thrown error', function () {
            expect(function () {
                expect.fail({
                    foobarquux: 123
                });
            }, 'to throw', {
                foobarquux: 123
            });
        });

        it('should support message passed as a string', function () {
            expect(function () {
                expect.fail({
                    message: 'hey'
                });
            }, 'to throw', {
                message: '\nhey'
            });
        });

        it('should support message passed as a MagicPen instance', function () {
            expect(function () {
                expect.fail({
                    message: expect.output.clone().text('hey')
                });
            }, 'to throw', {
                message: '\nhey'
            });
        });
    });
});

@@ -2549,13 +2549,1459 @@
 %0A    %7D);
+%0A%0A    describe('with a diff function', function () %7B%0A        it('should generate the diff', function () %7B%0A            var clonedExpect = expect.clone();%0A            clonedExpect.addAssertion('%3Cany%3E to foo', function (expect, subject, value) %7B%0A                expect.fail(%7B%0A                    diff: function (output, diff, inspect, equal) %7B%0A                        return output.text('custom');%0A                    %7D%0A                %7D);%0A            %7D);%0A            expect(function () %7B%0A                clonedExpect('bar', 'to foo');%0A            %7D, 'to throw',%0A                %22expected 'bar' to foo%5Cn%22 +%0A                %22%5Cn%22 +%0A                %22custom%22%0A            );%0A        %7D);%0A%0A        it('should support a diff function that uses the old API', function () %7B%0A            var clonedExpect = expect.clone();%0A            clonedExpect.addAssertion('%3Cany%3E to foo', function (expect, subject, value) %7B%0A                expect.fail(%7B%0A                    diff: function (output, diff, inspect, equal) %7B%0A                        return %7B%0A                            inline: false,%0A                            diff: output.text('custom')%0A                        %7D;%0A                    %7D%0A                %7D);%0A            %7D);%0A            expect(function () %7B%0A                clonedExpect('bar', 'to foo');%0A            %7D, 'to throw',%0A                %22expected 'bar' to foo%5Cn%22 +%0A                %22%5Cn%22 +%0A                %22custom%22%0A            );%0A        %7D);%0A    %7D);
 %0A%7D);%0A

Test that the old diff return values still work with expect.fail({diff: ...})