describe("autosubmit-plugin", function() {
    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,16 +1,85 @@
+/*global $, beforeEach, describe, expect, it, requireDependencies */%0A
 describe(%22autosu
@@ -96,29 +96,49 @@
 n%22, function
+ 
 () %7B%0A
+    %22use strict%22;%0A%0A
     var patt
@@ -200,16 +200,17 @@
 function
+ 
 (cls) %7B%0A
@@ -294,32 +294,33 @@
 oreEach(function
+ 
 () %7B%0A        $(%22
@@ -369,32 +369,33 @@
 parse%22, function
+ 
 () %7B%0A        it(
@@ -416,32 +416,33 @@
 ation%22, function
+ 
 () %7B%0A           
@@ -492,25 +492,25 @@
 it='500'/%3E%22)
-;
+,
 %0A           
@@ -653,32 +653,33 @@
 epted%22, function
+ 
 () %7B%0A           
@@ -740,17 +740,17 @@
 400'/%3E%22)
-;
+,
 %0A       
@@ -893,32 +893,33 @@
 tions%22, function
+ 
 () %7B%0A        var
@@ -1014,32 +1014,33 @@
 delay%22, function
+ 
 () %7B%0A           
@@ -1186,32 +1186,33 @@
 delay%22, function
+ 
 () %7B%0A           
@@ -1353,32 +1353,33 @@
 yword%22, function
+ 
 () %7B%0A           
@@ -1540,32 +1540,33 @@
  true%22, function
+ 
 () %7B%0A           
@@ -1723,32 +1723,33 @@
 yntax%22, function
+ 
 () %7B%0A           
@@ -1903,32 +1903,33 @@
  type%22, function
+ 
 () %7B%0A           
@@ -2093,16 +2093,17 @@
 function
+ 
 () %7B%0A   

Make code in autosubmit test JSlint-compliant