/*global $, beforeEach, describe, expect, it, requireDependencies */
describe("autosubmit-plugin", function () {
    "use strict";

    var pattern;

    requireDependencies(["patterns/autosubmit"], function (cls) {
        pattern = cls;
    });

    // Reset the lab before each test
    beforeEach(function () {
        $("#lab *").remove();
    });

    describe("parse", function () {
        it("Shorthand notation", function () {
            var $trigger = $("<input data-pat-autosubmit='500'/>"),
                options = pattern.parse($trigger);
            expect(options.delay).toBe("500");
        });

        it("Multiple options not accepted", function () {
            var $trigger = $("<input data-pat-autosubmit='500 && 400'/>"),
                options = pattern.parse($trigger);
            expect(options.delay).toBe("500");
        });
    });

    describe("validateOptions", function () {
        var defaultKeyupDelay = 400;  // as defined in patterns/autosubmit.js

        it("Integer delay", function () {
            var options = pattern.validateOptions({delay: 500});
            expect(options.delay).toBe(500);
        });

        it("String integer delay", function () {
            var options = pattern.validateOptions({delay: "500"});
            expect(options.delay).toBe(500);
        });

        it("Delay keyword", function () {
            var options = pattern.validateOptions({delay: "delay"});
            expect(options.delay).toBe(defaultKeyupDelay);
        });

        it("Delay set to true", function () {
            var options = pattern.validateOptions({delay: "true"});
            expect(options.delay).toBe(defaultKeyupDelay);
        });

        it("Invalid syntax", function () {
            var options = pattern.validateOptions({delay: "invalid"});
            expect(options.delay).toBe(defaultKeyupDelay);
        });

        it("Bad type", function () {
            var options = pattern.validateOptions({delay: [500]});
            expect(options.delay).toBe(defaultKeyupDelay);
        });

        it("Negative delay", function () {
            var options = pattern.validateOptions({delay: -500});
            expect(options.delay).toBe(defaultKeyupDelay);
        });

    });
});

// jshint indent: 4, browser: true, jquery: true, quotmark: double
// vim: sw=4 expandtab

@@ -1,73 +1,4 @@
-/*global $, beforeEach, describe, expect, it, requireDependencies */%0A
 desc
@@ -35,33 +35,13 @@
 tion
- 
 () %7B%0A
-    %22use strict%22;%0A%0A
     
@@ -111,17 +111,16 @@
 function
- 
 (cls) %7B%0A
@@ -204,33 +204,32 @@
 oreEach(function
- 
 () %7B%0A        $(%22
@@ -278,33 +278,32 @@
 parse%22, function
- 
 () %7B%0A        it(
@@ -324,33 +324,32 @@
 ation%22, function
- 
 () %7B%0A           
@@ -399,25 +399,25 @@
 it='500'/%3E%22)
-,
+;
 %0A           
@@ -560,33 +560,32 @@
 epted%22, function
- 
 () %7B%0A           
@@ -646,17 +646,17 @@
 400'/%3E%22)
-,
+;
 %0A       
@@ -799,33 +799,32 @@
 tions%22, function
- 
 () %7B%0A        var
@@ -919,33 +919,32 @@
 delay%22, function
- 
 () %7B%0A           
@@ -1090,33 +1090,32 @@
 delay%22, function
- 
 () %7B%0A           
@@ -1256,33 +1256,32 @@
 yword%22, function
- 
 () %7B%0A           
@@ -1442,33 +1442,32 @@
  true%22, function
- 
 () %7B%0A           
@@ -1624,33 +1624,32 @@
 yntax%22, function
- 
 () %7B%0A           
@@ -1803,33 +1803,32 @@
  type%22, function
- 
 () %7B%0A           
@@ -1992,17 +1992,16 @@
 function
- 
 () %7B%0A   

Revert "Make code in autosubmit test JSlint-compliant"