mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-02 15:25:26 +00:00

The website used to host every past test suite, copied into the www directory. We no longer need that on the website (and it makes the codebase impossible to search) so I removed all the old tests and the new tests are hosted simply at /test. I also replaced the www.js script with a simpler www.sh one (since we no longer need to do anything besides copying, really), which allowed me to remove a node dependency that was only used in that script.
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
describe("hx-select-oob attribute", function () {
|
|
beforeEach(function () {
|
|
this.server = makeServer();
|
|
clearWorkArea();
|
|
});
|
|
afterEach(function () {
|
|
this.server.restore();
|
|
clearWorkArea();
|
|
});
|
|
|
|
it('basic hx-select-oob works', function()
|
|
{
|
|
this.server.respondWith("GET", "/test", "<div id='d1'>foo</div><div id='d2'>bar</div>");
|
|
var div = make('<div hx-get="/test" hx-select="#d1" hx-select-oob="#d2"></div>');
|
|
make('<div id="d2"></div>');
|
|
div.click();
|
|
this.server.respond();
|
|
div.innerHTML.should.equal("<div id=\"d1\">foo</div>");
|
|
var div2 = byId('d2');
|
|
div2.innerHTML.should.equal("bar");
|
|
});
|
|
|
|
it('multiple hx-select-oobs works', function()
|
|
{
|
|
this.server.respondWith("GET", "/test", "<div id='d1'>foo</div><div id='d2'>bar</div><div id='d3'>bar</div>");
|
|
var div = make('<div hx-get="/test" hx-select="#d1" hx-select-oob="#d2, #d3"></div>');
|
|
make('<div id="d2"></div>');
|
|
make('<div id="d3"></div>');
|
|
div.click();
|
|
this.server.respond();
|
|
div.innerHTML.should.equal("<div id=\"d1\">foo</div>");
|
|
|
|
var div2 = byId('d2');
|
|
div2.innerHTML.should.equal("bar");
|
|
|
|
var div3 = byId('d2');
|
|
div3.innerHTML.should.equal("bar");
|
|
});
|
|
|
|
it('basic hx-select-oob ignores bad selector', function()
|
|
{
|
|
this.server.respondWith("GET", "/test", "<div id='d1'>foo</div><div id='d2'>bar</div>");
|
|
var div = make('<div hx-get="/test" hx-select="#d1" hx-select-oob="#bad"></div>');
|
|
make('<div id="d2"></div>');
|
|
div.click();
|
|
this.server.respond();
|
|
div.innerHTML.should.equal("<div id=\"d1\">foo</div>");
|
|
var div2 = byId('d2');
|
|
div2.innerHTML.should.equal("");
|
|
});
|
|
|
|
|
|
});
|
|
|