Skip to content

Commit

Permalink
ut
Browse files Browse the repository at this point in the history
  • Loading branch information
JingleH committed Nov 5, 2024
1 parent d7156a1 commit 4db82cc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
27 changes: 24 additions & 3 deletions test/unit/blocks/ribbon-banner/mocks/body.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
<div>
<div class="ribbon-banner dark">
<p>Dark</p>
<div class="ribbon-banner text-light">
<div>
<div><strong>Black Friday is on.</strong> 60 days free access to Adobe express Premium. Ends Nov 29. <a href="https://www.adobe.com/express/">Get offer</a></div>
</div>
<div>
<div><strong>#fa0f00</strong></div>
</div>
<div>
<div><strong>#000000</strong></div>
</div>
</div>
<div class="ribbon-banner light">
<p>Light</p>
<div class="ribbon-banner">
<div>
<div><strong>Black Friday is on.</strong> 60 days free access to Adobe express Premium. Ends Nov 29. <a href="https://www.adobe.com/express/">Get offer</a></div>
</div>
<div>
<div><strong>linear-gradient(98.07deg, #FF477B -21.45%, #5C5CE0 101.65%)</strong></div>
</div>
<div>
<div><strong>#e0e2ff</strong></div>
</div>
</div>
<div class="ribbon-banner gradient">
<p>Gradient</p>
<div class="ribbon-banner text-light">
<div>
<div><strong>Black Friday is on.</strong> 60 days free access to Adobe express Premium. Ends Nov 29. <a href="https://www.adobe.com/express/">Get offer</a></div>
</div>
<div>
<div></div>
</div>
<div>
<div><strong>linear-gradient(97.82deg, #FF477B 3.22%, #5C5CE0 52.58%, #318FFF 101.72%)</strong></div>
</div>
</div>
</div>
15 changes: 14 additions & 1 deletion test/unit/blocks/ribbon-banner/ribbon-banner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,21 @@ describe('ribbon-banner', () => {
});
it('adds all required classes', () => {
blocks.forEach((block) => {
expect(block.querySelector('.row')).to.exist;
expect(block.querySelector('.content')).to.exist;
expect(block.querySelector('a.button.reverse')).to.exist;
});
});
it('removes config rows', () => {
blocks.forEach((block) => {
expect(block.querySelectorAll(':scope > div').length).to.equal(1);
});
});
it('decorates keywords', () => {
expect(blocks[0].querySelector('strong').style.getPropertyValue('color')).to.equal('rgb(250, 15, 0)');
expect(blocks[2].querySelector('strong').style.getPropertyValue('color')).to.equal('');
});
it('decorates background', () => {
expect(blocks[0].style.getPropertyValue('background')).to.equal('rgb(0, 0, 0)');
expect(blocks[2].style.getPropertyValue('background')).to.equal('linear-gradient(97.82deg, rgb(255, 71, 123) 3.22%, rgb(92, 92, 224) 52.58%, rgb(49, 143, 255) 101.72%)');
});
});

0 comments on commit 4db82cc

Please sign in to comment.