@@ -1609,7 +1609,6 @@ describe("pat-inject", function () {
16091609
16101610 await utils . timeout ( 1 ) ; // wait a tick for async to settle.
16111611
1612- console . log ( document . body . innerHTML ) ;
16131612 const modal = document . querySelector ( "#pat-modal" ) ;
16141613 expect ( modal ) . toBeTruthy ( ) ;
16151614 expect ( modal . innerHTML . replace ( / \s / g, "" ) ) . toBe (
@@ -1644,7 +1643,6 @@ describe("pat-inject", function () {
16441643
16451644 await utils . timeout ( 1 ) ; // wait a tick for async to settle.
16461645
1647- console . log ( document . body . innerHTML ) ;
16481646 const modal = document . querySelector ( "#pat-modal" ) ;
16491647 expect ( modal ) . toBeFalsy ( ) ;
16501648 } ) ;
@@ -1742,6 +1740,56 @@ describe("pat-inject", function () {
17421740 expect ( title . textContent . trim ( ) ) . toBe ( "test" ) ; // Old title
17431741 } ) ;
17441742 } ) ;
1743+
1744+ describe ( "9.5 - support multiple source element matches." , function ( ) {
1745+ let spy_ajax ;
1746+
1747+ beforeEach ( function ( ) {
1748+ spy_ajax = jest . spyOn ( $ , "ajax" ) . mockImplementation ( ( ) => deferred ) ;
1749+ } ) ;
1750+
1751+ afterEach ( function ( ) {
1752+ spy_ajax . mockRestore ( ) ;
1753+ } ) ;
1754+
1755+ it ( "9.5.1 - Injects multiple source element matches" , async function ( ) {
1756+ document . body . innerHTML = `
1757+ <a class="pat-inject"
1758+ href="test.html"
1759+ data-pat-inject="
1760+ source: a::element;
1761+ target: .result;
1762+ ">link</a>
1763+ <section class="result">
1764+ </section>
1765+ ` ;
1766+
1767+ answer ( `
1768+ <html>
1769+ <body>
1770+ <a>Link 1</a>
1771+ <a>Link 2</a>
1772+ <a>Link 3</a>
1773+ </body>
1774+ </html>
1775+ ` ) ;
1776+
1777+ const inject = document . querySelector ( ".pat-inject" ) ;
1778+
1779+ pattern . init ( $ ( inject ) ) ;
1780+ await utils . timeout ( 1 ) ; // wait a tick for async to settle.
1781+
1782+ inject . click ( ) ;
1783+ await utils . timeout ( 1 ) ; // wait a tick for async to settle.
1784+
1785+ const injected = document . querySelectorAll ( ".result a" ) ;
1786+ expect ( injected . length ) . toBe ( 3 ) ;
1787+ expect ( injected [ 0 ] . textContent ) . toBe ( "Link 1" ) ;
1788+ expect ( injected [ 1 ] . textContent ) . toBe ( "Link 2" ) ;
1789+ expect ( injected [ 2 ] . textContent ) . toBe ( "Link 3" ) ;
1790+ } ) ;
1791+ } ) ;
1792+
17451793 } ) ;
17461794
17471795 describe ( "10 - Error handling" , ( ) => {
0 commit comments