describe('hx-select-oob', function() { beforeEach(() => { setupTest() }) afterEach(() => { cleanupTest() }) it('basic hx-select-oob works', async function () { mockResponse('GET', '/test', '
foo
bar
') let div = createProcessedHTML('
Click
') div.click() await forRequest() assertTextContentIs('#target', 'foo') assertTextContentIs('#d2', 'bar') }) it('multiple hx-select-oobs works', async function () { mockResponse('GET', '/test', '
foo
bar
baz
') let div = createProcessedHTML('
Click
') div.click() await forRequest() assertTextContentIs('#target', 'foo') assertTextContentIs('#d2', 'bar') assertTextContentIs('#d3', 'baz') }) it('basic hx-select-oob ignores bad selector', async function () { mockResponse('GET', '/test', '
foo
bar
') let div = createProcessedHTML('
Click
') div.click() await forRequest() assertTextContentIs('#target', 'foo') assertTextContentIs('#d2', '') }) it('hx-select-oob works with advanced swap style like strip:false and target:', async function () { mockResponse('GET', '/test', '
foo
bar
') createProcessedHTML('
Click
') find('[hx-get]').click() await forRequest() assertTextContentIs('#d0', 'foo') assertTextContentIs('#d2', 'bar') }) it('hx-select-oob works with basic targeting selector', async function () { mockResponse('GET', '/test', '
foo
bar
') let div = createProcessedHTML('
Click
') div.click() await forRequest() assertTextContentIs('#target', 'foo') assertTextContentIs('#d2', 'bar') assert.isNull(document.querySelector('.foo')) }) it('hx-select-oob can end with a blank swap style which is ignored', async function () { mockResponse('GET', '/test', '
foo
bar
') let div = createProcessedHTML('
Click
') div.click() await forRequest() assertTextContentIs('#target', 'foo') let div2 = document.getElementById('d2') assert.equal(div2.textContent, 'bar') assert.isTrue(div2.classList.contains('foo')) }) it('basic hx-select-oob works supports non text based selectors', async function () { mockResponse('GET', '/test', '
foo
bar
') let div = createProcessedHTML('
Click
') div.click() await forRequest() assertTextContentIs('#target', 'foo') let div2 = document.getElementById('d2') assert.equal(div2.textContent, 'bar') assert.isTrue(div2.classList.contains('foo')) }) it('basic hx-select-oob works with CSS escaped id containing "."', async function () { mockResponse('GET', '/test', '
foo
bar
') let div = createProcessedHTML('
Click
') div.click() await forRequest() assertTextContentIs('#target', 'foo') assertTextContentIs('#my\\.div3', 'bar') }) it('hx-select-oob can select multiple elements with a selector', async function () { mockResponse('GET', '/test', '
foo
bar
baz
') let div = createProcessedHTML('
Click
') div.click() await forRequest() assertTextContentIs('#target', 'foo') let div2 = document.getElementById('d2') assert.equal(div2.textContent, 'bar') assert.isTrue(div2.classList.contains('foo')) let div3 = document.getElementById('d3') assert.equal(div3.textContent, 'baz') assert.isTrue(div3.classList.contains('foo')) }) })