mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-28 21:41:40 +00:00
polling test
This commit is contained in:
parent
280d8e4534
commit
4b2ace772b
4
TODO.md
4
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
describe("BOOTSTRAP - kutty AJAX Tests", function(){
|
||||
describe("GENERAL - kutty AJAX Tests", function(){
|
||||
beforeEach(function() {
|
||||
this.server = makeServer();
|
||||
clearWorkArea();
|
@ -1,4 +1,4 @@
|
||||
describe("BOOTSTRAP - kutty Value Handling", function() {
|
||||
describe("GENERAL - kutty Value Handling", function() {
|
||||
beforeEach(function () {
|
||||
this.server = makeServer();
|
||||
clearWorkArea();
|
@ -1,4 +1,4 @@
|
||||
describe("BOOTSTRAP - kutty AJAX Verbs", function() {
|
||||
describe("GENERAL - kutty AJAX Verbs", function() {
|
||||
beforeEach(function () {
|
||||
this.server = makeServer();
|
||||
clearWorkArea();
|
@ -26,11 +26,12 @@
|
||||
<script src="util.js"></script>
|
||||
|
||||
<!-- bootstrap tests -->
|
||||
<script src="bootstrap-ajax.js"></script>
|
||||
<script src="bootstrap-verbs.js"></script>
|
||||
<script src="bootstrap-values.js"></script>
|
||||
<script src="general-ajax.js"></script>
|
||||
<script src="general-verbs.js"></script>
|
||||
<script src="general-values.js"></script>
|
||||
|
||||
<!-- attribute tests -->
|
||||
<script src="kt-boost.js"></script>
|
||||
<script src="kt-classes.js"></script>
|
||||
<script src="kt-delete.js"></script>
|
||||
<script src="kt-error-url.js"></script>
|
||||
|
@ -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('<div kt-push-url="true" kt-get="/test">first</div>');
|
||||
div.click();
|
||||
this.server.respondWith("GET", "/test1", '<div id="d2" kt-push-url="true" kt-get="/test2" kt-swap="outerHTML settle:0">test1</div>');
|
||||
this.server.respondWith("GET", "/test2", '<div id="d3" kt-push-url="true" kt-get="/test3" kt-swap="outerHTML settle:0">test2</div>');
|
||||
|
||||
make('<div id="d1" kt-push-url="true" kt-get="/test1" kt-swap="outerHTML settle:0">init</div>');
|
||||
|
||||
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 () {
|
||||
|
@ -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('<div kt-trigger="every 10ms" kt-get="/test"/>');
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user