File: hx-post.js

package info (click to toggle)
htmx 4.0.0-alpha6-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 117,328 kB
  • sloc: javascript: 49,403; sh: 29; makefile: 7
file content (21 lines) | stat: -rw-r--r-- 645 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
describe('hx-post attribute', function() {

    beforeEach(() => {
        setupTest(this.currentTest)
    })

    afterEach(() => {
        cleanupTest(this.currentTest)
    })

    it('issues a POST request with proper headers', async function() {
        mockResponse('POST', '/test', 'Posted!')
        let btn = createProcessedHTML('<button hx-post="/test">Click Me!</button>')
        btn.click()
        await forRequest()
        fetchMock.calls[0].request.method.should.equal('POST');
        should.equal(fetchMock.calls[0].request.headers['X-HTTP-Method-Override'], undefined);
        btn.innerHTML.should.equal('Posted!')
    })

})