Skip to content

Commit 9549fec

Browse files
dazgreerCopilot
andcommitted
test(beautify): align beautify-output tests with js-beautify formatter following rebase
The beautify tests were written against the old Prettier formatter. Now that mjml-core uses js-beautify, two fixtures needed updating: - "keeps raw html comment spacing": js-beautify does not insert a space after HTML comments, so expectedBeautified now matches actual output. Added skipFragmentDiffCheck: true since the fragment is unchanged by beautify (the document-level check still asserts overall reformatting). - "wraps long raw html start tags": deleted. js-beautify uses wrap_line_length: 0 by default and does not split long attribute lists across lines. The same input is already covered by the passing standalone it() "keeps long raw html start tags and attributes intact while beautifying". Also deleted a duplicate standalone it() for the comment-spacing case that searched for <tbody> as its start token. MJML never emits that tag inside an mj-raw block, so the test always failed with "Missing start token". Co-authored-by: Copilot <copilot@github.com>
1 parent d4a17d6 commit 9549fec

1 file changed

Lines changed: 2 additions & 74 deletions

File tree

packages/mjml/test/beautify-output.test.js

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ describe('Beautify output', function () {
110110
},
111111
{
112112
name: 'keeps raw html comment spacing while reindenting the surrounding block',
113+
skipFragmentDiffCheck: true,
113114
input: `
114115
<mjml>
115116
<mj-body>
@@ -134,42 +135,7 @@ describe('Beautify output', function () {
134135
'<div id="beautify-raw-comment"><!-- keep this spacing --><span data-kind="raw">Raw</span></div>',
135136
].join('\n'),
136137
expectedBeautified: [
137-
'<div id="beautify-raw-comment"><!-- keep this spacing --> <span data-kind="raw">Raw</span></div>',
138-
].join('\n'),
139-
},
140-
{
141-
name: 'wraps long raw html start tags according to the configured print width',
142-
input: `
143-
<mjml>
144-
<mj-body>
145-
<mj-section>
146-
<mj-column>
147-
<mj-raw>
148-
<div id="beautify-print-width-probe" data-alpha="${'a'.repeat(80)}" data-beta="${'b'.repeat(80)}" data-gamma="${'c'.repeat(80)}" data-delta="${'d'.repeat(80)}">Wrapped raw tag</div>
149-
</mj-raw>
150-
</mj-column>
151-
</mj-section>
152-
</mj-body>
153-
</mjml>
154-
`,
155-
extract: (html) =>
156-
extractBlockAroundMarker(html, {
157-
marker: 'id="beautify-print-width-probe"',
158-
startToken: '<div',
159-
endToken: '</div>',
160-
label: 'print width probe',
161-
}),
162-
expectedPlain: `<div id="beautify-print-width-probe" data-alpha="${'a'.repeat(80)}" data-beta="${'b'.repeat(80)}" data-gamma="${'c'.repeat(80)}" data-delta="${'d'.repeat(80)}">Wrapped raw tag</div>`,
163-
expectedBeautified: [
164-
'<div',
165-
' id="beautify-print-width-probe"',
166-
` data-alpha="${'a'.repeat(80)}"`,
167-
` data-beta="${'b'.repeat(80)}"`,
168-
` data-gamma="${'c'.repeat(80)}"`,
169-
` data-delta="${'d'.repeat(80)}"`,
170-
' >',
171-
' Wrapped raw tag',
172-
' </div>',
138+
'<div id="beautify-raw-comment"><!-- keep this spacing --><span data-kind="raw">Raw</span></div>',
173139
].join('\n'),
174140
},
175141
]
@@ -201,44 +167,6 @@ describe('Beautify output', function () {
201167
})
202168
})
203169

204-
it('keeps raw html comment spacing while reindenting the surrounding block', async function () {
205-
const input = `
206-
<mjml>
207-
<mj-body>
208-
<mj-section>
209-
<mj-column>
210-
<mj-raw>
211-
<div id="beautify-raw-comment"><!-- keep this spacing --><span data-kind="raw">Raw</span></div>
212-
</mj-raw>
213-
</mj-column>
214-
</mj-section>
215-
</mj-body>
216-
</mjml>
217-
`
218-
219-
const { plainHtml, beautifiedHtml } = await renderVariants(input)
220-
221-
const plainFragment = extractBlockAroundMarker(plainHtml, {
222-
marker: 'id="beautify-raw-comment"',
223-
startToken: '<tbody>',
224-
endToken: '</tbody>',
225-
label: 'raw comment block (plain)',
226-
})
227-
const beautifiedFragment = extractBlockAroundMarker(beautifiedHtml, {
228-
marker: 'id="beautify-raw-comment"',
229-
startToken: '<tbody>',
230-
endToken: '</tbody>',
231-
label: 'raw comment block (beautified)',
232-
})
233-
234-
chai.expect(plainFragment).to.include('<!-- keep this spacing -->')
235-
chai.expect(beautifiedFragment).to.include('<!-- keep this spacing -->')
236-
chai.expect(beautifiedFragment).to.match(
237-
/<!--\s{3}keep this spacing\s{3}-->\s*<span data-kind="raw">Raw<\/span>/,
238-
)
239-
chai.expect(beautifiedHtml).to.not.equal(plainHtml)
240-
})
241-
242170
it('keeps long raw html start tags and attributes intact while beautifying', async function () {
243171
const input = `
244172
<mjml>

0 commit comments

Comments
 (0)