'use strict';

const RuleTester = require('eslint').RuleTester;
const rules = require('../../').rules;
const ruleTester = new RuleTester();

ruleTester.run('valid-test-description', rules['valid-test-description'], {
    valid: [
        'it("should respond to GET", function() { });',
        'it("should do something");',
        'specify("should respond to GET", function() { });',
        'specify("should do something");',
        'test("should respond to GET", function() { });',
        'test("should do something");',
        'it();',
        'specify();',
        'test();',
        {
            options: [ 'test' ],
            code: 'it("this is a test", function () { });'
        },
        {
            options: [ 'test' ],
            code: 'test("this is a test", function () { });'
        },
        {
            options: [ '^should', [ 'someFunction' ] ],
            code: 'it("this is a test", function () { });'
        },
        {
            options: [ '^should', [ 'someFunction' ] ],
            code: 'someFunction("should do something", function () { });'
        },
        'someOtherFunction();',
        {
            parserOptions: { ecmaVersion: 2017 },
            code: 'it(`should work with template strings`, function () {});'
        }
    ],

    invalid: [
        {
            code: 'it("does something", function() { });',
            errors: [
                { message: 'Invalid "it()" description found.' }
            ]
        },
        {
            code: 'specify("does something", function() { });',
            errors: [
                { message: 'Invalid "specify()" description found.' }
            ]
        },
        {
            code: 'test("does something", function() { });',
            errors: [
                { message: 'Invalid "test()" description found.' }
            ]
        },
        {
            options: [ 'required' ],
            code: 'it("this is a test", function () { });',
            errors: [
                { message: 'Invalid "it()" description found.' }
            ]
        },
        {
            options: [ 'required' ],
            code: 'specify("this is a test", function () { });',
            errors: [
                { message: 'Invalid "specify()" description found.' }
            ]
        },
        {
            options: [ 'required' ],
            code: 'test("this is a test", function () { });',
            errors: [
                { message: 'Invalid "test()" description found.' }
            ]
        },
        {
            options: [ 'required', [ 'customFunction' ] ],
            code: 'customFunction("this is a test", function () { });',
            errors: [
                { message: 'Invalid "customFunction()" description found.' }
            ]
        }
    ]
});

@@ -1084,32 +1084,790 @@
 %7D);'%0A        %7D,%0A
+        %7B%0A            options: %5B '%5Eshould', %5B 'someFunction' %5D, 'some error message' %5D,%0A            code: 'someFunction(%22should do something%22, function () %7B %7D);'%0A        %7D,%0A        %7B%0A            options: %5B /%5Eshould/, %5B 'someFunction' %5D, 'some error message' %5D,%0A            code: 'someFunction(%22should do something%22, function () %7B %7D);'%0A        %7D,%0A        %7B%0A            options: %5B %7B pattern: '%5Eshould', testNames: %5B 'someFunction' %5D, message: 'some error message' %7D %5D,%0A            code: 'someFunction(%22should do something%22, function () %7B %7D);'%0A        %7D,%0A        %7B%0A            options: %5B %7B pattern: /%5Eshould/, testNames: %5B 'someFunction' %5D, message: 'some error message' %7D %5D,%0A            code: 'someFunction(%22should do something%22, function () %7B %7D);'%0A        %7D,%0A
         'someOth
@@ -3526,32 +3526,796 @@
 %7D%0A            %5D%0A
+        %7D,%0A        %7B%0A            options: %5B 'required', %5B 'customFunction' %5D, 'some error message' %5D,%0A            code: 'customFunction(%22this is a test%22, function () %7B %7D);',%0A            errors: %5B%0A                %7B message: 'some error message' %7D%0A            %5D%0A        %7D,%0A        %7B%0A            options: %5B %7B pattern: 'required', testNames: %5B 'customFunction' %5D, message: 'some error message' %7D %5D,%0A            code: 'customFunction(%22this is a test%22, function () %7B %7D);',%0A            errors: %5B%0A                %7B message: 'some error message' %7D%0A            %5D%0A        %7D,%0A        %7B%0A            options: %5B %7B%7D %5D,%0A            code: 'it(%22this is a test%22, function () %7B %7D);',%0A            errors: %5B%0A                %7B message: 'Invalid %22it()%22 description found.' %7D%0A            %5D%0A
         %7D%0A    %5D%0A

Test addition of custom message for valid-test-description rule