mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-30 06:21:19 +00:00
polling test
This commit is contained in:
parent
280d8e4534
commit
4b2ace772b
4
TODO.md
4
TODO.md
@ -7,9 +7,6 @@
|
|||||||
## TODOS
|
## TODOS
|
||||||
|
|
||||||
* Testing
|
* Testing
|
||||||
* history
|
|
||||||
* polling
|
|
||||||
* kt-boost
|
|
||||||
* interval parsing
|
* interval parsing
|
||||||
* table elements in responses
|
* table elements in responses
|
||||||
* scrolling/'revealed' event
|
* scrolling/'revealed' event
|
||||||
@ -27,7 +24,6 @@
|
|||||||
* `kutty-requests` class on body
|
* `kutty-requests` class on body
|
||||||
* local references (e.g. kt-get="#foo")
|
* local references (e.g. kt-get="#foo")
|
||||||
* polling cancellation API 205 code
|
* polling cancellation API 205 code
|
||||||
* meta config tag
|
|
||||||
* focus recapture
|
* focus recapture
|
||||||
* kutty javascript API
|
* kutty javascript API
|
||||||
* find
|
* find
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
describe("BOOTSTRAP - kutty AJAX Tests", function(){
|
describe("GENERAL - kutty AJAX Tests", function(){
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
this.server = makeServer();
|
this.server = makeServer();
|
||||||
clearWorkArea();
|
clearWorkArea();
|
@ -1,4 +1,4 @@
|
|||||||
describe("BOOTSTRAP - kutty Value Handling", function() {
|
describe("GENERAL - kutty Value Handling", function() {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.server = makeServer();
|
this.server = makeServer();
|
||||||
clearWorkArea();
|
clearWorkArea();
|
@ -1,4 +1,4 @@
|
|||||||
describe("BOOTSTRAP - kutty AJAX Verbs", function() {
|
describe("GENERAL - kutty AJAX Verbs", function() {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.server = makeServer();
|
this.server = makeServer();
|
||||||
clearWorkArea();
|
clearWorkArea();
|
@ -26,11 +26,12 @@
|
|||||||
<script src="util.js"></script>
|
<script src="util.js"></script>
|
||||||
|
|
||||||
<!-- bootstrap tests -->
|
<!-- bootstrap tests -->
|
||||||
<script src="bootstrap-ajax.js"></script>
|
<script src="general-ajax.js"></script>
|
||||||
<script src="bootstrap-verbs.js"></script>
|
<script src="general-verbs.js"></script>
|
||||||
<script src="bootstrap-values.js"></script>
|
<script src="general-values.js"></script>
|
||||||
|
|
||||||
<!-- attribute tests -->
|
<!-- attribute tests -->
|
||||||
|
<script src="kt-boost.js"></script>
|
||||||
<script src="kt-classes.js"></script>
|
<script src="kt-classes.js"></script>
|
||||||
<script src="kt-delete.js"></script>
|
<script src="kt-delete.js"></script>
|
||||||
<script src="kt-error-url.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 () {
|
it("restore should return old value", function () {
|
||||||
this.server.respondWith("GET", "/test", "second");
|
this.server.respondWith("GET", "/test1", '<div id="d2" kt-push-url="true" kt-get="/test2" kt-swap="outerHTML settle:0">test1</div>');
|
||||||
getWorkArea().innerHTML.should.be.equal("");
|
this.server.respondWith("GET", "/test2", '<div id="d3" kt-push-url="true" kt-get="/test3" kt-swap="outerHTML settle:0">test2</div>');
|
||||||
var div = make('<div kt-push-url="true" kt-get="/test">first</div>');
|
|
||||||
div.click();
|
make('<div id="d1" kt-push-url="true" kt-get="/test1" kt-swap="outerHTML settle:0">init</div>');
|
||||||
|
|
||||||
|
byId("d1").click();
|
||||||
this.server.respond();
|
this.server.respond();
|
||||||
getWorkArea().textContent.should.equal("second")
|
var workArea = getWorkArea();
|
||||||
kutty._('restoreHistory')(location.pathname+location.search)
|
workArea.textContent.should.equal("test1")
|
||||||
getWorkArea().textContent.should.equal("first")
|
|
||||||
|
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 () {
|
it("cache should only store 10 entries", function () {
|
||||||
|
@ -67,5 +67,20 @@ describe("kt-trigger attribute", function(){
|
|||||||
div.innerHTML.should.equal("Requests: 1");
|
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