From 26f1caaf57023e89ea15ae35a54ed6741d46d152 Mon Sep 17 00:00:00 2001
From: Diana Huang <dkh@edx.org>
Date: Wed, 21 Aug 2013 13:53:58 -0400
Subject: [PATCH] Add jsinput_spec back in.

---
 common/static/js/capa/spec/jsinput_spec.js | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 common/static/js/capa/spec/jsinput_spec.js

diff --git a/common/static/js/capa/spec/jsinput_spec.js b/common/static/js/capa/spec/jsinput_spec.js
new file mode 100644
index 0000000..a4a4f6e
--- /dev/null
+++ b/common/static/js/capa/spec/jsinput_spec.js
@@ -0,0 +1,70 @@
+xdescribe("A jsinput has:", function () {
+
+    beforeEach(function () {
+        $('#fixture').remove();
+        $.ajax({
+            async: false,
+            url: 'mainfixture.html',
+            success: function(data) {
+                $('body').append($(data));
+            }
+        });
+    });
+
+
+
+    describe("The jsinput constructor", function(){
+
+        var iframe1 = $(document).find('iframe')[0];
+
+        var testJsElem = jsinputConstructor({
+            id: 1,
+            elem: iframe1,
+            passive: false
+        });
+
+        it("Returns an object", function(){
+            expect(typeof(testJsElem)).toEqual('object');
+        });
+
+        it("Adds the object to the jsinput array", function() {
+            expect(jsinput.exists(1)).toBe(true);
+        });
+
+        describe("The returned object", function() {
+
+            it("Has a public 'update' method", function(){
+                expect(testJsElem.update).toBeDefined();  
+            });
+
+            it("Returns an 'update' that is idempotent", function(){
+                var orig = testJsElem.update();
+                for (var i = 0; i++; i < 5) {
+                    expect(testJsElem.update()).toEqual(orig);
+                }
+            });
+
+            it("Changes the parent's inputfield", function() {
+                testJsElem.update();
+              
+            });
+        });
+    });
+
+
+    describe("The walkDOM functions", function() {
+
+        walkDOM();
+
+        it("Creates (at least) one object per iframe", function() {
+            jsinput.arr.length >= 2; 
+        });
+
+        it("Does not create multiple objects with the same id", function() {
+            while (jsinput.arr.length > 0) {
+                var elem = jsinput.arr.pop();
+                expect(jsinput.exists(elem.id)).toBe(false);
+            }
+        });
+    });
+})
--
libgit2 0.26.0