module("core");

test("Requirements", function() {
  expect(2);

  ok(jQuery, "jQuery exists");
  ok($, "$ exists");
});

test("Constructor", function() {
  expect(19);

  var $test1 = $("#testForm1").autosave();
  var test1 = $test1.data("autosave");

  equal(typeof test1, "object", "test1 contains an autosave instance");
  equal(test1.$elements.length, 1, "test1 was invoked with one valid element");
  equal(test1.$forms.length, 1, "test1 includes one form element");
  equal(test1.$fields.length, 10, "test1 includes ten form input elements");

  var test1events = test1.$fields.data("events");

  ok(test1events.change || test1events.propertychange, "test1 is listening for changes to form fields");

  var callbackOptions = ["triggers", "filters", "conditions", "methods"];

  $.each(callbackOptions, function(i, name) {
    ok($.isArray(test1.options[name]), "test1 options." + name + " is an array");

    $.each(test1.options[name], function(i, callback) {
      equal(typeof callback, "object", "test1 options." + name + "[" + i + "] is an object");
      ok($.isFunction(callback.method), "test1 options." + name + "[" + i + "] is a function");
    });
  });

  var $test2 = $("#testForm1").autosave();
  var test2 = $test2.data("autosave");

  equal(typeof test2, "object", "test2 contains an autosave instance");
  deepEqual(test2, test1, "test2 refers to the same autosave instance as test1");

  var $test3 = $("#testForm1 :input").autosave();
  var test3 = $test3.data("autosave");

  equal(test3.$elements.length, 10, "test3 was invoked with ten valid elements");
  notDeepEqual(test3, test2, "test3 does not refer to the same autosave instance as test2");

  var $test4 = $("#invalidElement1").autosave();
  var test4 = $test4.data("autosave");

  equal(test4, undefined, "test4 does not contain an autosave instance");

  var $test5 = $("#invalidElement2").autosave();
  var test5 = $test5.data("autosave");

  equal(test5, undefined, "test5 does not contain an autosave instance");
});

@@ -161,10 +161,10 @@
 ect(
-19
+24
 );%0A%0A
@@ -705,83 +705,8 @@
 );%0A%0A
-  var callbackOptions = %5B%22triggers%22, %22filters%22, %22conditions%22, %22methods%22%5D;%0A%0A
   $.
@@ -710,24 +710,30 @@
  $.each(
+test1.
 callback
 Options,
@@ -728,14 +728,8 @@
 back
-Option
 s, f
@@ -740,23 +740,27 @@
 ion(
-i, 
 name
+, value
 ) %7B%0A    
 ok($
@@ -751,26 +751,29 @@
 alue) %7B%0A    
-ok
+equal
 ($.isArray(t
@@ -775,43 +775,37 @@
 ray(
-test1.options%5Bname%5D), %22test1 option
+value), true, %22test1 callback
 s.%22 
@@ -846,27 +846,13 @@
 ach(
-test1.options%5Bname%5D
+value
 , fu
@@ -911,38 +911,40 @@
 object%22, %22test1 
-option
+callback
 s.%22 + name + %22%5B%22
@@ -975,18 +975,21 @@
 ;%0A      
-ok
+equal
 ($.isFun
@@ -1011,24 +1011,30 @@
 method),
+ true,
  %22test1 
 options.
@@ -1029,14 +1029,16 @@
 st1 
-option
+callback
 s.%22 
@@ -1054,24 +1054,31 @@
 %22%5B%22 + i + %22%5D
+.method
  is a functi

Update tests to reflect current plugin state