|
| 1 | +const chai = require('chai') |
| 2 | +const { load } = require('cheerio') |
| 3 | +const mjml = require('../lib') |
| 4 | + |
| 5 | +describe('mj-table cellspacing', function () { |
| 6 | + it('should render correct cellspacing (and border-collapse) in HTML tag / CSS style values on mj-table', function () { |
| 7 | + const input = ` |
| 8 | + <mjml> |
| 9 | + <mj-body> |
| 10 | + <mj-section> |
| 11 | + <mj-column> |
| 12 | + <mj-table border="1px solid #000" width="auto" cellpadding="20" cellspacing="10" css-class="my-table"> |
| 13 | + <tr style="border-bottom:1px solid #000;text-align:left;"> |
| 14 | + <th style="background:#ddd;">Year</th> |
| 15 | + <th style="background:#ddd;">Language</th> |
| 16 | + <th style="background:#ddd;">Inspired from</th> |
| 17 | + </tr> |
| 18 | + <tr> |
| 19 | + <td style="background:#ddd;">1995</td> |
| 20 | + <td style="background:#ddd;">PHP</td> |
| 21 | + <td style="background:#ddd;">C, Shell Unix</td> |
| 22 | + </tr> |
| 23 | + </mj-table> |
| 24 | + </mj-column> |
| 25 | + </mj-section> |
| 26 | + </mj-body> |
| 27 | + </mjml> |
| 28 | + ` |
| 29 | + |
| 30 | + const { html } = mjml(input) |
| 31 | + |
| 32 | + const $ = load(html) |
| 33 | + |
| 34 | + // border radius values should be correct |
| 35 | + chai |
| 36 | + .expect( |
| 37 | + $('.my-table > table') |
| 38 | + .map(function getAttr() { |
| 39 | + return $(this).attr('cellspacing') |
| 40 | + }) |
| 41 | + .get(), |
| 42 | + 'cellspacing values on table elements', |
| 43 | + ) |
| 44 | + .to.eql(['10']) |
| 45 | + |
| 46 | + // border collapse values should be correct |
| 47 | + chai |
| 48 | + .expect( |
| 49 | + $('.my-table > table') |
| 50 | + .map(function getAttr() { |
| 51 | + const start = $(this).attr('style').indexOf('border-collapse:') + 16 |
| 52 | + const end = $(this).attr('style').indexOf(';', start) |
| 53 | + return $(this).attr('style').substring(start, end) |
| 54 | + }) |
| 55 | + .get(), |
| 56 | + 'Border-collapse in CSS style values on mj-table', |
| 57 | + ) |
| 58 | + .to.eql(['separate']) |
| 59 | + }) |
| 60 | +}) |
0 commit comments