summaryrefslogtreecommitdiffstatshomepage
path: root/www/static/test/attributes/hx-patch.js
blob: b8ac5be8b49008c72c69592ddfebc542096f6643 (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
28
29
30
31
32
describe('hx-patch attribute', function() {
  beforeEach(function() {
    this.server = makeServer()
    clearWorkArea()
  })
  afterEach(function() {
    this.server.restore()
    clearWorkArea()
  })

  it('issues a PATCH request', function() {
    this.server.respondWith('PATCH', '/test', function(xhr) {
      xhr.respond(200, {}, 'Patched!')
    })

    var btn = make('<button hx-patch="/test">Click Me!</button>')
    btn.click()
    this.server.respond()
    btn.innerHTML.should.equal('Patched!')
  })

  it('issues a PATCH request w/ data-* prefix', function() {
    this.server.respondWith('PATCH', '/test', function(xhr) {
      xhr.respond(200, {}, 'Patched!')
    })

    var btn = make('<button data-hx-patch="/test">Click Me!</button>')
    btn.click()
    this.server.respond()
    btn.innerHTML.should.equal('Patched!')
  })
})