Testing Jquery selector with Jasmine unit tests
<pre><code>$('.froala &gt; div &gt; div &gt; div &gt; p').each(function (index, element) {
                        if ($(element).text() !== '') {
                            wordCount += $(element).text().split(' ').length;
                        }
                    });
</code></pre>

<p>I have this code that gets all the &lt; p > tags in the froala editor and counts them. I need to write a Jasmine unit test to cover this and I don't have a clue how to do that. Maybe I could use a spyOn and return an array of &lt; p > tags... </p>

<pre><code>spyOn($('.froala &gt; div &gt; div &gt; div &gt; p'), 'each').and.returnValue([all, my, tags, here]);
</code></pre>

<p>Any other ideas?</p>