| 1 | describe('BOOTSTRAP - htmx AJAX Tests', function() { |
| 2 | beforeEach(function() { |
| 3 | this.server = makeServer() |
| 4 | clearWorkArea() |
| 5 | }) |
| 6 | afterEach(function() { |
| 7 | this.server.restore() |
| 8 | clearWorkArea() |
| 9 | }) |
| 10 | |
| 11 | it('properly handles a partial of HTML', function() { |
| 12 | var i = 1 |
| 13 | this.server.respondWith('GET', '/test', "<div id='d1'>foo</div><div id='d2'>bar</div>") |
| 14 | var div = make('<div hx-get="/test" hx-select="#d1"></div>') |
| 15 | div.click() |
| 16 | this.server.respond() |
| 17 | div.innerHTML.should.equal('<div id="d1">foo</div>') |
| 18 | }) |
| 19 | |
| 20 | it('properly handles a full HTML document', function() { |
| 21 | var i = 1 |
| 22 | this.server.respondWith('GET', '/test', "<html><body><div id='d1'>foo</div><div id='d2'>bar</div></body></html>") |
| 23 | var div = make('<div hx-get="/test" hx-select="#d1"></div>') |
| 24 | div.click() |
| 25 | this.server.respond() |
| 26 | div.innerHTML.should.equal('<div id="d1">foo</div>') |
| 27 | }) |
| 28 | |
| 29 | it('properly handles a full HTML document w/ data-* prefix', function() { |
| 30 | var i = 1 |
| 31 | this.server.respondWith('GET', '/test', "<html><body><div id='d1'>foo</div><div id='d2'>bar</div></body></html>") |
| 32 | var div = make('<div hx-get="/test" data-hx-select="#d1"></div>') |
| 33 | div.click() |
| 34 | this.server.respond() |
| 35 | div.innerHTML.should.equal('<div id="d1">foo</div>') |
| 36 | }) |
| 37 | }) |