-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathhx-custom-verb-wildcard.js
More file actions
51 lines (43 loc) · 1.85 KB
/
hx-custom-verb-wildcard.js
File metadata and controls
51 lines (43 loc) · 1.85 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
describe('hx-custom-verb attribute', function() {
beforeEach(function() {
this.server = makeServer()
clearWorkArea()
})
afterEach(function() {
this.server.restore()
clearWorkArea()
})
it('issues a custom verb request', function() {
this.server.respondWith('RESET_PASSWORD', '/test', function(xhr) {
xhr.respond(200, {}, 'Password reset!')
})
make('<script lang="js">htmx.config.customVerbs.push(\'reset_password\')</script>')
var btn = make('<button hx-custom-verb-reset_password="/test">Click me!</button>')
btn.click()
this.server.respond()
btn.innerHTML.should.equal('Password reset!')
make('<script lang="js">htmx.config.customVerbs = htmx.config.customVerbs.filter((verb) => verb !== \'reset_password\')</script>')
})
it('issues a custom verb request w/ data-* prefix', function() {
this.server.respondWith('RESET_PASSWORD', '/test', function(xhr) {
xhr.respond(200, {}, 'Password reset!')
})
make('<script lang="js">htmx.config.customVerbs.push(\'reset_password\')</script>')
var btn = make('<button data-hx-custom-verb-reset_password="/test">Click me!</button>')
btn.click()
this.server.respond()
btn.innerHTML.should.equal('Password reset!')
make('<script lang="js">htmx.config.customVerbs = htmx.config.customVerbs.filter((verb) => verb !== \'reset_password\')</script>')
})
it('does not issues a custom verb request if the config is not set', function() {
this.server.respondWith('RESET_PASSWORD', '/test', function(xhr) {
xhr.respond(200, {}, 'Password reset!')
})
// Do not add configuration to prove effectiveness
var btn = make('<button hx-custom-verb-reset_password="/test">Click me!</button>')
btn.click()
this.server.respond()
btn.innerHTML.should.not.equal('Password reset!')
btn.innerHTML.should.equal('Click me!')
})
})