Skip to content

Commit

Permalink
chore(mjml-react): add test for mjml attributes with custom selector
Browse files Browse the repository at this point in the history
  • Loading branch information
mastertheblaster committed Feb 24, 2022
1 parent e72830a commit 0a17a43
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion test/render.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import React from 'react';
import { expect } from 'chai';

import { render, Mjml, MjmlHead, MjmlTitle, MjmlBody, MjmlRaw } from '../src';
import {
render,
Mjml,
MjmlHead,
MjmlTitle,
MjmlBody,
MjmlRaw,
MjmlSection,
MjmlHtmlAttribute,
MjmlHtmlAttributes,
MjmlSelector,
MjmlColumn,
MjmlText,
} from '../src';

describe('render()', () => {
it('should render the HTML', () => {
Expand Down Expand Up @@ -54,4 +67,32 @@ describe('render()', () => {
"Element div doesn't exist or is not registered",
);
});

it('should render html attributes with custom selector', () => {
const email = (
<Mjml>
<MjmlHead>
<MjmlHtmlAttributes>
<MjmlSelector path=".custom div">
<MjmlHtmlAttribute name="data-id">42</MjmlHtmlAttribute>
</MjmlSelector>
</MjmlHtmlAttributes>
</MjmlHead>
<MjmlBody>
<MjmlSection>
<MjmlColumn>
<MjmlText css-class="custom">Hello World!</MjmlText>
</MjmlColumn>
</MjmlSection>
</MjmlBody>
</Mjml>
);
const { html } = render(email, {
validationLevel: 'soft',
minify: false,
});
expect(html).contains(
'<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;" data-id="42">Hello World!</div>',
);
});
});

0 comments on commit 0a17a43

Please sign in to comment.