summaryrefslogtreecommitdiffstatshomepage
path: root/test/attributes/hx-error-url.js
blob: 1984edcc8080626c3697a3f8bb2c1ba0dd5c6448 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
describe("hx-error-url attribute", function(){
    beforeEach(function() {
        this.server = makeServer();
        clearWorkArea();
    });
    afterEach(function()  {
        this.server.restore();
        clearWorkArea();
    });

    it('Submits a POST with error content on bad request', function()
    {
        this.server.respondWith("POST", "/error", function(xhr){
            should.equal(JSON.parse(xhr.requestBody).detail.xhr.status, 404);
        });
        var btn = make('<button hx-error-url="/error" hx-get="/bad">Click Me!</button>')
        btn.click();
        this.server.respond();
        this.server.respond();
    });
})