| 1 | describe('hx-include attribute', function() { |
| 2 | |
| 3 | beforeEach(() => { |
| 4 | setupTest(this.currentTest) |
| 5 | }) |
| 6 | |
| 7 | afterEach(() => { |
| 8 | cleanupTest(this.currentTest) |
| 9 | }) |
| 10 | |
| 11 | it('By default an input includes itself', async function () { |
| 12 | mockResponse('POST', '/include', "Clicked!") |
| 13 | createProcessedHTML('<div hx-target="this"><input hx-post="/include" hx-trigger="click" id="i1" name="i1" value="test"/></div>') |
| 14 | find("#i1").click() |
| 15 | await forRequest() |
| 16 | fetchMock.calls[0].request.body.get("i1").should.equal("test"); |
| 17 | }) |
| 18 | |
| 19 | it('checked checkbox via hx-include is sent', async function () { |
| 20 | mockResponse('GET', '/include', "OK") |
| 21 | createProcessedHTML('<input type="checkbox" id="cb" name="notify" checked><button id="btn" hx-get="/include" hx-include="#cb">Go</button>') |
| 22 | find('#btn').click() |
| 23 | await forRequest() |
| 24 | new URL(fetchMock.calls[0].url, location.href).searchParams.get('notify').should.equal('on') |
| 25 | }) |
| 26 | |
| 27 | it('unchecked checkbox via hx-include is not sent', async function () { |
| 28 | mockResponse('GET', '/include', "OK") |
| 29 | createProcessedHTML('<input type="checkbox" id="cb" name="notify"><button id="btn" hx-get="/include" hx-include="#cb">Go</button>') |
| 30 | find('#btn').click() |
| 31 | await forRequest() |
| 32 | assert.equal(new URL(fetchMock.calls[0].url, location.href).searchParams.get('notify'), null) |
| 33 | }) |
| 34 | |
| 35 | |
| 36 | it('non-GET includes closest form', async function () { |
| 37 | mockResponse('POST', '/include', "Dummy") |
| 38 | createProcessedHTML('<form hx-target="this"><div id="d1" hx-post="/include"></div><input name="i1" value="test"/></form>') |
| 39 | find('#d1').click() |
| 40 | await forRequest() |
| 41 | fetchMock.calls[0].request.body.get("i1").should.equal("test"); |
| 42 | }) |
| 43 | |
| 44 | it('Single input not included twice when in form', async function () { |
| 45 | mockResponse('POST', '/include', "Dummy") |
| 46 | createProcessedHTML('<form hx-target="this"><input hx-post="/include" hx-trigger="click" id="i1" name="i1" value="test"/></form>') |
| 47 | find('#i1').click() |
| 48 | await forRequest() |
| 49 | fetchMock.calls[0].request.body.getAll("i1").length.should.equal(1); |
| 50 | }) |
| 51 | |
| 52 | // it('non-GET includes closest form and overrides values included that exist outside the form', function() { |
| 53 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 54 | // var params = getParameters(xhr) |
| 55 | // params.i1.should.equal('test') |
| 56 | // xhr.respond(200, {}, 'Clicked!') |
| 57 | // }) |
| 58 | // var div = make('<div hx-include="*" hx-target="this">' + |
| 59 | // '<input name="i1" value="before"/>' + |
| 60 | // '<form><div id="d1" hx-post="/include"></div><input name="i1" value="test"/></form>' + |
| 61 | // '<input name="i1" value="after"/>') |
| 62 | // var input = byId('d1') |
| 63 | // input.click() |
| 64 | // this.server.respond() |
| 65 | // div.innerHTML.should.equal('Clicked!') |
| 66 | // }) |
| 67 | // |
| 68 | // it('GET does not include closest form by default', function() { |
| 69 | // this.server.respondWith('GET', '/include', function(xhr) { |
| 70 | // var params = getParameters(xhr) |
| 71 | // should.equal(params.i1, undefined) |
| 72 | // xhr.respond(200, {}, 'Clicked!') |
| 73 | // }) |
| 74 | // var div = make('<form hx-target="this"><div id="d1" hx-get="/include"></div><input name="i1" value="test"/></form>') |
| 75 | // var input = byId('d1') |
| 76 | // input.click() |
| 77 | // this.server.respond() |
| 78 | // div.innerHTML.should.equal('Clicked!') |
| 79 | // }) |
| 80 | // |
| 81 | |
| 82 | // |
| 83 | // it('Two inputs are included twice when they have the same name', function() { |
| 84 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 85 | // var params = getParameters(xhr) |
| 86 | // params.i1.should.deep.equal(['test', 'test2']) |
| 87 | // xhr.respond(200, {}, 'Clicked!') |
| 88 | // }) |
| 89 | // var div = make('<div hx-include="*" hx-target="this">' + |
| 90 | // '<input hx-post="/include" hx-trigger="click" id="i1" name="i1" value="test"/>' + |
| 91 | // '<input name="i1" value="test2"/>' + |
| 92 | // '</div>') |
| 93 | // var input = byId('i1') |
| 94 | // input.click() |
| 95 | // this.server.respond() |
| 96 | // div.innerHTML.should.equal('Clicked!') |
| 97 | // }) |
| 98 | // |
| 99 | // it('Two inputs are included twice when in form when they have the same name', function() { |
| 100 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 101 | // var params = getParameters(xhr) |
| 102 | // params.i1.should.deep.equal(['test', 'test2']) |
| 103 | // xhr.respond(200, {}, 'Clicked!') |
| 104 | // }) |
| 105 | // var div = make('<form hx-target="this">' + |
| 106 | // '<input hx-post="/include" hx-trigger="click" id="i1" name="i1" value="test"/>' + |
| 107 | // '<input name="i1" value="test2"/>' + |
| 108 | // '</form>') |
| 109 | // var input = byId('i1') |
| 110 | // input.click() |
| 111 | // this.server.respond() |
| 112 | // div.innerHTML.should.equal('Clicked!') |
| 113 | // }) |
| 114 | // |
| 115 | // it('Input not included twice when it explicitly refers to parent form', function() { |
| 116 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 117 | // var params = getParameters(xhr) |
| 118 | // params.i1.should.equal('test') |
| 119 | // xhr.respond(200, {}, 'Clicked!') |
| 120 | // }) |
| 121 | // var div = make('<form id="f1" hx-target="this">' + |
| 122 | // '<input hx-include="#f1" hx-post="/include" hx-trigger="click" id="i1" name="i1" value="test"/>' + |
| 123 | // '</form>') |
| 124 | // var input = byId('i1') |
| 125 | // input.click() |
| 126 | // this.server.respond() |
| 127 | // div.innerHTML.should.equal('Clicked!') |
| 128 | // }) |
| 129 | // |
| 130 | // it('Input can be referred to externally', function() { |
| 131 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 132 | // var params = getParameters(xhr) |
| 133 | // params.i1.should.equal('test') |
| 134 | // xhr.respond(200, {}, 'Clicked!') |
| 135 | // }) |
| 136 | // make('<input id="i1" name="i1" value="test"/>') |
| 137 | // var div = make('<div hx-post="/include" hx-include="#i1"></div>') |
| 138 | // div.click() |
| 139 | // this.server.respond() |
| 140 | // div.innerHTML.should.equal('Clicked!') |
| 141 | // }) |
| 142 | // |
| 143 | // it('Input can be referred to externally and then via a form then it will only be included once', function() { |
| 144 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 145 | // var params = getParameters(xhr) |
| 146 | // params.i1.should.equal('test') |
| 147 | // xhr.respond(200, {}, 'Clicked!') |
| 148 | // }) |
| 149 | // make('<form id="f1"><input id="i1" name="i1" value="test"/></form>') |
| 150 | // var div = make('<div hx-post="/include" hx-include="previous #i1,#f1"></div>') |
| 151 | // div.click() |
| 152 | // this.server.respond() |
| 153 | // div.innerHTML.should.equal('Clicked!') |
| 154 | // }) |
| 155 | // |
| 156 | // it('checkbox can be referred to externally', function() { |
| 157 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 158 | // var params = getParameters(xhr) |
| 159 | // params.i1.should.equal('on') |
| 160 | // xhr.respond(200, {}, 'Clicked!') |
| 161 | // }) |
| 162 | // make('<input id="i1" name="i1" type="checkbox" checked/>') |
| 163 | // var div = make('<div hx-post="/include" hx-include="#i1"></div>') |
| 164 | // div.click() |
| 165 | // this.server.respond() |
| 166 | // div.innerHTML.should.equal('Clicked!') |
| 167 | // }) |
| 168 | // |
| 169 | // it('files input can be referred to externally', function() { |
| 170 | // // This test is just to make loc coverage complete and does not test that real file values are sent |
| 171 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 172 | // xhr.respond(200, {}, 'Clicked!') |
| 173 | // }) |
| 174 | // make('<input id="i1" name="i1" type="file" multiple/>') |
| 175 | // var div = make('<div hx-post="/include" hx-include="#i1"></div>') |
| 176 | // div.click() |
| 177 | // this.server.respond() |
| 178 | // div.innerHTML.should.equal('Clicked!') |
| 179 | // }) |
| 180 | // |
| 181 | // it('properly handles multiple select input referred to externally', function() { |
| 182 | // var values |
| 183 | // this.server.respondWith('Post', '/include', function(xhr) { |
| 184 | // values = getParameters(xhr) |
| 185 | // xhr.respond(204, {}, '') |
| 186 | // }) |
| 187 | // make('<select id="multiSelect" name="multiSelect" multiple="multiple">' + |
| 188 | // '<option id="m1" value="m1">m1</option>' + |
| 189 | // '<option id="m2" value="m2">m2</option>' + |
| 190 | // '<option id="m3" value="m3">m3</option>' + |
| 191 | // '<option id="m4" value="m4">m4</option>' + |
| 192 | // '</select>') |
| 193 | // var div = make('<div hx-post="/include" hx-include="#multiSelect"></div>') |
| 194 | // |
| 195 | // div.click() |
| 196 | // this.server.respond() |
| 197 | // values.should.deep.equal({}) |
| 198 | // |
| 199 | // byId('m1').selected = true |
| 200 | // div.click() |
| 201 | // this.server.respond() |
| 202 | // values.should.deep.equal({ multiSelect: 'm1' }) |
| 203 | // |
| 204 | // byId('m1').selected = true |
| 205 | // byId('m3').selected = true |
| 206 | // div.click() |
| 207 | // this.server.respond() |
| 208 | // values.should.deep.equal({ multiSelect: ['m1', 'm3'] }) |
| 209 | // }) |
| 210 | // |
| 211 | // it('properly handles multiple select input referred to externally and then via a form then it will only be included once', function() { |
| 212 | // var values |
| 213 | // this.server.respondWith('Post', '/include', function(xhr) { |
| 214 | // values = getParameters(xhr) |
| 215 | // xhr.respond(204, {}, '') |
| 216 | // }) |
| 217 | // make('<form id="f1"><select id="multiSelect" name="multiSelect" multiple="multiple">' + |
| 218 | // '<option id="m1" value="m1">m1</option>' + |
| 219 | // '<option id="m2" value="m2">m2</option>' + |
| 220 | // '<option id="m3" value="m3">m3</option>' + |
| 221 | // '<option id="m4" value="m4">m4</option>' + |
| 222 | // '</select></form>') |
| 223 | // var div = make('<div hx-post="/include" hx-include="previous #multiSelect,#f1"></div>') |
| 224 | // |
| 225 | // div.click() |
| 226 | // this.server.respond() |
| 227 | // values.should.deep.equal({}) |
| 228 | // |
| 229 | // byId('m1').selected = true |
| 230 | // div.click() |
| 231 | // this.server.respond() |
| 232 | // values.should.deep.equal({ multiSelect: 'm1' }) |
| 233 | // |
| 234 | // byId('m1').selected = true |
| 235 | // byId('m3').selected = true |
| 236 | // div.click() |
| 237 | // this.server.respond() |
| 238 | // values.should.deep.equal({ multiSelect: ['m1', 'm3'] }) |
| 239 | // }) |
| 240 | // |
| 241 | // it('Two inputs can be referred to externally', function() { |
| 242 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 243 | // var params = getParameters(xhr) |
| 244 | // params.i1.should.equal('test') |
| 245 | // params.i2.should.equal('test') |
| 246 | // xhr.respond(200, {}, 'Clicked!') |
| 247 | // }) |
| 248 | // make('<input id="i1" name="i1" value="test"/>') |
| 249 | // make('<input id="i2" name="i2" value="test"/>') |
| 250 | // var div = make('<div hx-post="/include" hx-include="#i1, #i2"></div>') |
| 251 | // div.click() |
| 252 | // this.server.respond() |
| 253 | // div.innerHTML.should.equal('Clicked!') |
| 254 | // }) |
| 255 | // |
| 256 | // it('A form can be referred to externally', function() { |
| 257 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 258 | // var params = getParameters(xhr) |
| 259 | // params.i1.should.equal('test') |
| 260 | // params.i2.should.equal('test') |
| 261 | // xhr.respond(200, {}, 'Clicked!') |
| 262 | // }) |
| 263 | // make('<form id="f1">' + |
| 264 | // '<input name="i1" value="test"/>' + |
| 265 | // '<input name="i2" value="test"/>' + |
| 266 | // '</form> ') |
| 267 | // var div = make('<div hx-post="/include" hx-include="#f1"></div>') |
| 268 | // div.click() |
| 269 | // this.server.respond() |
| 270 | // div.innerHTML.should.equal('Clicked!') |
| 271 | // }) |
| 272 | // |
| 273 | // it('By default an input includes itself w/ data-* prefix', function() { |
| 274 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 275 | // var params = getParameters(xhr) |
| 276 | // params.i1.should.equal('test') |
| 277 | // xhr.respond(200, {}, 'Clicked!') |
| 278 | // }) |
| 279 | // var div = make('<div data-hx-target="this"><input data-hx-post="/include" data-hx-trigger="click" id="i1" name="i1" value="test"/></div>') |
| 280 | // var input = byId('i1') |
| 281 | // input.click() |
| 282 | // this.server.respond() |
| 283 | // div.innerHTML.should.equal('Clicked!') |
| 284 | // }) |
| 285 | // |
| 286 | // it('If the element is not includeable, its descendant inputs are included', function() { |
| 287 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 288 | // var params = getParameters(xhr) |
| 289 | // params.i1.should.equal('test') |
| 290 | // params.i2.should.equal('test') |
| 291 | // xhr.respond(200, {}, 'Clicked!') |
| 292 | // }) |
| 293 | // make('<div id="i"><input name="i1" value="test"/><input name="i2" value="test"/></div>') |
| 294 | // var div = make('<div hx-post="/include" hx-include="#i"></div>') |
| 295 | // div.click() |
| 296 | // this.server.respond() |
| 297 | // div.innerHTML.should.equal('Clicked!') |
| 298 | // }) |
| 299 | // |
| 300 | // it('The `closest` modifier can be used in the hx-include selector', function() { |
| 301 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 302 | // var params = getParameters(xhr) |
| 303 | // params.i1.should.equal('test') |
| 304 | // params.i2.should.equal('test') |
| 305 | // xhr.respond(200, {}, 'Clicked!') |
| 306 | // }) |
| 307 | // make('<div id="i"><input name="i1" value="test"/><input name="i2" value="test"/>' + |
| 308 | // '<button id="btn" hx-post="/include" hx-include="closest div"></button></div>') |
| 309 | // var btn = byId('btn') |
| 310 | // btn.click() |
| 311 | // this.server.respond() |
| 312 | // btn.innerHTML.should.equal('Clicked!') |
| 313 | // }) |
| 314 | // |
| 315 | // it('The `this` modifier can be used in the hx-include selector', function() { |
| 316 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 317 | // var params = getParameters(xhr) |
| 318 | // params.i1.should.equal('test') |
| 319 | // params.i2.should.equal('test') |
| 320 | // xhr.respond(200, {}, 'Clicked!') |
| 321 | // }) |
| 322 | // make('<div id="i" hx-include="this"><input name="i1" value="test"/><input name="i2" value="test"/>' + |
| 323 | // '<button id="btn" hx-post="/include"></button></div>') |
| 324 | // var btn = byId('btn') |
| 325 | // btn.click() |
| 326 | // this.server.respond() |
| 327 | // btn.innerHTML.should.equal('Clicked!') |
| 328 | // }) |
| 329 | // |
| 330 | // it('Multiple extended selectors can be used in hx-include', function() { |
| 331 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 332 | // var params = getParameters(xhr) |
| 333 | // params.i1.should.equal('test') |
| 334 | // params.i2.should.equal('foo') |
| 335 | // params.i3.should.equal('bar') |
| 336 | // params.i4.should.equal('test2') |
| 337 | // xhr.respond(200, {}, 'Clicked!') |
| 338 | // }) |
| 339 | // make('<input name="i4" value="test2" id="i4"/>' + |
| 340 | // '<div id="i">' + |
| 341 | // '<input name="i1" value="test"/>' + |
| 342 | // '<input name="i2" value="foo"/>' + |
| 343 | // '<button id="btn" hx-post="/include" hx-include="closest div, next input, #i4"></button>' + |
| 344 | // '</div>' + |
| 345 | // '<input name="i3" value="bar"/>') |
| 346 | // var btn = byId('btn') |
| 347 | // btn.click() |
| 348 | // this.server.respond() |
| 349 | // btn.innerHTML.should.equal('Clicked!') |
| 350 | // }) |
| 351 | // |
| 352 | // it('hx-include processes extended selector in between standard selectors', function() { |
| 353 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 354 | // var params = getParameters(xhr) |
| 355 | // params.i1.should.equal('test') |
| 356 | // should.equal(params.i2, undefined) |
| 357 | // params.i3.should.equal('bar') |
| 358 | // params.i4.should.equal('test2') |
| 359 | // xhr.respond(200, {}, 'Clicked!') |
| 360 | // }) |
| 361 | // make('<input name="i4" value="test2" id="i4"/>' + |
| 362 | // '<div id="i">' + |
| 363 | // '<input name="i1" value="test" id="i1"/>' + |
| 364 | // '<input name="i2" value="foo"/>' + |
| 365 | // '<button id="btn" hx-post="/include" hx-include="#i1, next input, #i4"></button>' + |
| 366 | // '</div>' + |
| 367 | // '<input name="i3" value="bar"/>') |
| 368 | // var btn = byId('btn') |
| 369 | // btn.click() |
| 370 | // this.server.respond() |
| 371 | // btn.innerHTML.should.equal('Clicked!') |
| 372 | // }) |
| 373 | // |
| 374 | // it('hx-include processes nested standard selectors correctly', function() { |
| 375 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 376 | // var params = getParameters(xhr) |
| 377 | // params.i1.should.equal('test') |
| 378 | // params.i2.should.equal('foo') |
| 379 | // params.i3.should.equal('bar') |
| 380 | // should.equal(params.i4, undefined) |
| 381 | // should.equal(params.i5, undefined) |
| 382 | // xhr.respond(200, {}, 'Clicked!') |
| 383 | // }) |
| 384 | // make('<input name="i4" value="test2" id="i4"/>' + |
| 385 | // '<div id="i">' + |
| 386 | // '<input name="i1" value="test" id="i1"/>' + |
| 387 | // '<input name="i2" value="foo"/>' + |
| 388 | // '<input name="i5" value="test"/>' + |
| 389 | // '<button id="btn" hx-post="/include" hx-include="next input, #i > :is([name=\'i1\'], [name=\'i2\'])"></button>' + |
| 390 | // '</div>' + |
| 391 | // '<input name="i3" value="bar"/>') |
| 392 | // var btn = byId('btn') |
| 393 | // btn.click() |
| 394 | // this.server.respond() |
| 395 | // btn.innerHTML.should.equal('Clicked!') |
| 396 | // }) |
| 397 | // |
| 398 | // it('hx-include processes wrapped next/previous selectors correctly', function() { |
| 399 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 400 | // var params = getParameters(xhr) |
| 401 | // should.equal(params.i1, undefined) |
| 402 | // params.i2.should.equal('foo') |
| 403 | // params.i3.should.equal('bar') |
| 404 | // should.equal(params.i4, undefined) |
| 405 | // should.equal(params.i5, undefined) |
| 406 | // xhr.respond(200, {}, 'Clicked!') |
| 407 | // }) |
| 408 | // make('<input name="i4" value="test2" id="i4"/>' + |
| 409 | // '<div id="i">' + |
| 410 | // '<input name="i1" value="test" id="i1"/>' + |
| 411 | // '<input name="i2" value="foo"/>' + |
| 412 | // '<button id="btn" hx-post="/include" hx-include="next <#nonexistent, input/>, previous <#i5, [name=\'i2\'], #i4/>"></button>' + |
| 413 | // '</div>' + |
| 414 | // '<input name="i3" value="bar"/>' + |
| 415 | // '<input name="i5" value="test"/>') |
| 416 | // var btn = byId('btn') |
| 417 | // btn.click() |
| 418 | // this.server.respond() |
| 419 | // btn.innerHTML.should.equal('Clicked!') |
| 420 | // }) |
| 421 | // |
| 422 | // it('hx-include processes wrapped closest selector correctly', function() { |
| 423 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 424 | // var params = getParameters(xhr) |
| 425 | // should.equal(params.i1, undefined) |
| 426 | // params.i2.should.equal('bar') |
| 427 | // xhr.respond(200, {}, 'Clicked!') |
| 428 | // }) |
| 429 | // make('<section>' + |
| 430 | // '<input name="i1" value="foo"/>' + |
| 431 | // '<div>' + |
| 432 | // '<input name="i2" value="bar"/>' + |
| 433 | // '<button id="btn" hx-post="/include" hx-include="closest <section, div/>"></button>' + |
| 434 | // '</div>' + |
| 435 | // '</section>') |
| 436 | // var btn = byId('btn') |
| 437 | // btn.click() |
| 438 | // this.server.respond() |
| 439 | // btn.innerHTML.should.equal('Clicked!') |
| 440 | // }) |
| 441 | // |
| 442 | // it('`inherit` can be used to expand parent hx-include', function() { |
| 443 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 444 | // var params = getParameters(xhr) |
| 445 | // params.i1.should.equal('test1') |
| 446 | // params.i2.should.equal('test2') |
| 447 | // xhr.respond(200, {}, 'Clicked!') |
| 448 | // }) |
| 449 | // make('<div hx-include="#i1">' + |
| 450 | // ' <button id="btn" hx-include="inherit, #i2" hx-post="/include"></button>' + |
| 451 | // '</div>' + |
| 452 | // '<input id="i1" name="i1" value="test1"/>' + |
| 453 | // '<input id="i2" name="i2" value="test2"/>') |
| 454 | // var btn = byId('btn') |
| 455 | // btn.click() |
| 456 | // this.server.respond() |
| 457 | // btn.innerHTML.should.equal('Clicked!') |
| 458 | // }) |
| 459 | // |
| 460 | // it('`inherit` can be used to expand multiple parents hx-include', function() { |
| 461 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 462 | // var params = getParameters(xhr) |
| 463 | // params.i1.should.equal('test1') |
| 464 | // params.i2.should.equal('test2') |
| 465 | // params.i3.should.equal('test3') |
| 466 | // xhr.respond(200, {}, 'Clicked!') |
| 467 | // }) |
| 468 | // make('<div hx-include="#i1">' + |
| 469 | // ' <div hx-include="inherit, #i2">' + |
| 470 | // ' <button id="btn" hx-include="inherit, #i3" hx-post="/include"></button>' + |
| 471 | // ' </div>' + |
| 472 | // '</div>' + |
| 473 | // '<input id="i1" name="i1" value="test1"/>' + |
| 474 | // '<input id="i2" name="i2" value="test2"/>' + |
| 475 | // '<input id="i3" name="i3" value="test3"/>') |
| 476 | // var btn = byId('btn') |
| 477 | // btn.click() |
| 478 | // this.server.respond() |
| 479 | // btn.innerHTML.should.equal('Clicked!') |
| 480 | // }) |
| 481 | // |
| 482 | // it('`inherit` chain breaks properly', function() { |
| 483 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 484 | // var params = getParameters(xhr) |
| 485 | // should.not.exist(params.i1) |
| 486 | // params.i2.should.equal('test2') |
| 487 | // params.i3.should.equal('test3') |
| 488 | // xhr.respond(200, {}, 'Clicked!') |
| 489 | // }) |
| 490 | // make('<div hx-include="#i1">' + |
| 491 | // ' <div hx-include="#i2">' + |
| 492 | // ' <button id="btn" hx-include="inherit, #i3" hx-post="/include"></button>' + |
| 493 | // ' </div>' + |
| 494 | // '</div>' + |
| 495 | // '<input id="i1" name="i1" value="test1"/>' + |
| 496 | // '<input id="i2" name="i2" value="test2"/>' + |
| 497 | // '<input id="i3" name="i3" value="test3"/>') |
| 498 | // var btn = byId('btn') |
| 499 | // btn.click() |
| 500 | // this.server.respond() |
| 501 | // btn.innerHTML.should.equal('Clicked!') |
| 502 | // }) |
| 503 | // |
| 504 | // it('`inherit` syntax regex properly catches keyword', function() { |
| 505 | // this.server.respondWith('POST', '/include', function(xhr) { |
| 506 | // var params = getParameters(xhr) |
| 507 | // params.i1.should.equal('test1') |
| 508 | // params.i2.should.equal('test2') |
| 509 | // params.i3.should.equal('test3') |
| 510 | // xhr.respond(200, {}, 'Clicked!') |
| 511 | // }) |
| 512 | // make('<div hx-include="#i1">' + |
| 513 | // ' <div hx-include="#i2, inherit,.nonexistent-class">' + |
| 514 | // ' <button id="btn" hx-include="customtag,inherit , #i3" hx-post="/include"></button>' + |
| 515 | // ' </div>' + |
| 516 | // '</div>' + |
| 517 | // '<input id="i1" name="i1" value="test1"/>' + |
| 518 | // '<input id="i2" name="i2" value="test2"/>' + |
| 519 | // '<input id="i3" name="i3" value="test3"/>') |
| 520 | // var btn = byId('btn') |
| 521 | // btn.click() |
| 522 | // this.server.respond() |
| 523 | // btn.innerHTML.should.equal('Clicked!') |
| 524 | // }) |
| 525 | }) |