summaryrefslogtreecommitdiffstatshomepage
path: root/test/ext/bad-extension.js
blob: 3f38748dd3de97ceee12cbdbde81cc9c1e8a8d59 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
describe("bad extension", function() {
    htmx.defineExtension("bad-extension", {
            onEvent : function(name, evt) {throw "onEvent"},
            transformResponse : function(text, xhr, elt) {throw "transformRequest"},
            isInlineSwap : function(swapStyle) {throw "isInlineSwap"},
            handleSwap : function(swapStyle, target, fragment, settleInfo) {throw "handleSwap"},
            encodeParameters : function(xhr, parameters, elt) {throw "encodeParameters"}
        }
    )
    beforeEach(function () {
        this.server = makeServer();
        clearWorkArea();
    });
    afterEach(function () {
        this.server.restore();
        clearWorkArea();
    });

    it('does not blow up rendering', function () {
        this.server.respondWith("GET", "/test", "clicked!");
        var div = make('<div hx-get="/test" hx-ext="bad-extension">Click Me!</div>')
        div.click();
        this.server.respond();
        div.innerHTML.should.equal("clicked!");
    });

});