|
| 1 | +const chai = require('chai') |
| 2 | +const { load } = require('cheerio') |
| 3 | +const mjml = require('../lib') |
| 4 | + |
| 5 | +describe('mj-accordion font-family inheritance', function () { |
| 6 | + it('should render correct font-family in CSS style values on accordion-title and accordion-text', function () { |
| 7 | + const input = ` |
| 8 | + <mjml> |
| 9 | + <mj-body> |
| 10 | + <mj-section> |
| 11 | + <mj-column> |
| 12 | + <mj-accordion css-class="my-accordion-1" font-family="serif"> |
| 13 | + <mj-accordion-element> |
| 14 | + <mj-accordion-title>Why use an accordion?</mj-accordion-title> |
| 15 | + <mj-accordion-text> |
| 16 | + Because emails with a lot of content are most of the time a very bad experience on mobile, mj-accordion comes handy when you want to deliver a lot of information in a concise way. |
| 17 | + </mj-accordion-text> |
| 18 | + </mj-accordion-element> |
| 19 | + </mj-accordion> |
| 20 | + </mj-column> |
| 21 | + </mj-section> |
| 22 | + <mj-section> |
| 23 | + <mj-column> |
| 24 | + <mj-accordion css-class="my-accordion-2" font-family="serif"> |
| 25 | + <mj-accordion-element font-family="sans-serif"> |
| 26 | + <mj-accordion-title font-family="monospace">Why use an accordion?</mj-accordion-title> |
| 27 | + <mj-accordion-text font-family="monospace"> |
| 28 | + Because emails with a lot of content are most of the time a very bad experience on mobile, mj-accordion comes handy when you want to deliver a lot of information in a concise way. |
| 29 | + </mj-accordion-text> |
| 30 | + </mj-accordion-element> |
| 31 | + </mj-accordion> |
| 32 | + </mj-column> |
| 33 | + </mj-section> |
| 34 | + </mj-body> |
| 35 | + </mjml> |
| 36 | + ` |
| 37 | + |
| 38 | + const { html } = mjml(input) |
| 39 | + |
| 40 | + const $ = load(html) |
| 41 | + |
| 42 | + // style values should be correct |
| 43 | + chai |
| 44 | + .expect( |
| 45 | + $( |
| 46 | + '.my-accordion-1 .mj-accordion-title td:first-child, .my-accordion-1 .mj-accordion-content td:first-child', |
| 47 | + '.my-accordion-2 .mj-accordion-title td:first-child, .my-accordion-2 .mj-accordion-content td:first-child, ', |
| 48 | + ) |
| 49 | + .map(function getAttr() { |
| 50 | + const start = $(this).attr('style').indexOf('font-family:') + 12 |
| 51 | + const end = $(this).attr('style').indexOf(';', start) |
| 52 | + const result = $(this).attr('style').substring(start, end) |
| 53 | + return result |
| 54 | + }) |
| 55 | + .get(), |
| 56 | + 'Font-family in CSS style values on accordion-title', |
| 57 | + ) |
| 58 | + .to.eql(['serif', 'serif', 'monospace', 'monospace']) |
| 59 | + }) |
| 60 | +}) |
0 commit comments