diff --git a/TODO.md b/TODO.md index 23fa16f5..31f176b9 100644 --- a/TODO.md +++ b/TODO.md @@ -7,9 +7,6 @@ ## TODOS * Testing - * history - * polling - * kt-boost * interval parsing * table elements in responses * scrolling/'revealed' event @@ -27,7 +24,6 @@ * `kutty-requests` class on body * local references (e.g. kt-get="#foo") * polling cancellation API 205 code -* meta config tag * focus recapture * kutty javascript API * find diff --git a/test/bootstrap-ajax.js b/test/general-ajax.js similarity index 99% rename from test/bootstrap-ajax.js rename to test/general-ajax.js index c8cc7e97..908787ca 100644 --- a/test/bootstrap-ajax.js +++ b/test/general-ajax.js @@ -1,4 +1,4 @@ -describe("BOOTSTRAP - kutty AJAX Tests", function(){ +describe("GENERAL - kutty AJAX Tests", function(){ beforeEach(function() { this.server = makeServer(); clearWorkArea(); diff --git a/test/bootstrap-values.js b/test/general-values.js similarity index 98% rename from test/bootstrap-values.js rename to test/general-values.js index 2f04ebdf..9e6485b6 100644 --- a/test/bootstrap-values.js +++ b/test/general-values.js @@ -1,4 +1,4 @@ -describe("BOOTSTRAP - kutty Value Handling", function() { +describe("GENERAL - kutty Value Handling", function() { beforeEach(function () { this.server = makeServer(); clearWorkArea(); diff --git a/test/bootstrap-verbs.js b/test/general-verbs.js similarity index 96% rename from test/bootstrap-verbs.js rename to test/general-verbs.js index 0dd6883d..9da5834a 100644 --- a/test/bootstrap-verbs.js +++ b/test/general-verbs.js @@ -1,4 +1,4 @@ -describe("BOOTSTRAP - kutty AJAX Verbs", function() { +describe("GENERAL - kutty AJAX Verbs", function() { beforeEach(function () { this.server = makeServer(); clearWorkArea(); diff --git a/test/index.html b/test/index.html index 5640d9ba..2457d532 100644 --- a/test/index.html +++ b/test/index.html @@ -26,11 +26,12 @@ - - - + + + + diff --git a/test/kt-push-url.js b/test/kt-push-url.js index cc8f150b..c1763e2b 100644 --- a/test/kt-push-url.js +++ b/test/kt-push-url.js @@ -24,14 +24,26 @@ describe("kt-push-url attribute", function() { }); it("restore should return old value", function () { - this.server.respondWith("GET", "/test", "second"); - getWorkArea().innerHTML.should.be.equal(""); - var div = make('
first
'); - div.click(); + this.server.respondWith("GET", "/test1", '
test1
'); + this.server.respondWith("GET", "/test2", '
test2
'); + + make('
init
'); + + byId("d1").click(); this.server.respond(); - getWorkArea().textContent.should.equal("second") - kutty._('restoreHistory')(location.pathname+location.search) - getWorkArea().textContent.should.equal("first") + var workArea = getWorkArea(); + workArea.textContent.should.equal("test1") + + byId("d2").click(); + this.server.respond(); + workArea.textContent.should.equal("test2") + + var cache = JSON.parse(localStorage.getItem(KUTTY_HISTORY_CACHE)); + + cache.length.should.equal(2); + kutty._('restoreHistory')("/test1") + this.server.respond(); + getWorkArea().textContent.should.equal("test1") }); it("cache should only store 10 entries", function () { diff --git a/test/kt-trigger.js b/test/kt-trigger.js index 723d1c80..7b844693 100644 --- a/test/kt-trigger.js +++ b/test/kt-trigger.js @@ -67,5 +67,20 @@ describe("kt-trigger attribute", function(){ div.innerHTML.should.equal("Requests: 1"); }); + it('polling works', function(complete) + { + var requests = 0; + this.server.respondWith("GET", "/test", function (xhr) { + requests++; + xhr.respond(200, {}, "Requests: " + requests); + if (requests > 5) { + complete(); + } + }); + this.server.autoRespond = true; + this.server.autoRespondAfter = 0; + make('
'); + }); + })