Skip to content

Commit 18d31c0

Browse files
committed
test: quoteStyle option
1 parent 903300f commit 18d31c0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/render.test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,5 +371,37 @@ describe('PostHTML Render', () => {
371371
expect(render(fixture, options)).to.eql(expected);
372372
});
373373
});
374+
375+
describe('quoteStyle', () => {
376+
it('1 - single quote', () => {
377+
const options = {replaceQuote: false, quoteStyle: 1};
378+
379+
const fixture = {tag: 'img', attrs: {src: 'https://example.com/example.png', onload: 'testFunc("test")'}};
380+
const expected = '<img src=\'https://example.com/example.png\' onload=\'testFunc("test")\'>';
381+
382+
fs.writeFileSync('test.html', render(fixture, options));
383+
expect(render(fixture, options)).to.eql(expected);
384+
});
385+
386+
it('2 - double quote', () => {
387+
const options = {replaceQuote: false, quoteStyle: 2};
388+
389+
const fixture = {tag: 'img', attrs: {src: 'https://example.com/example.png', onload: 'testFunc("test")'}};
390+
const expected = '<img src="https://example.com/example.png" onload="testFunc("test")">';
391+
392+
fs.writeFileSync('test.html', render(fixture, options));
393+
expect(render(fixture, options)).to.eql(expected);
394+
});
395+
396+
it('0 - smart quote', () => {
397+
const options = {replaceQuote: false, quoteStyle: 0};
398+
399+
const fixture = {tag: 'img', attrs: {src: 'https://example.com/example.png', onload: 'testFunc("test")'}};
400+
const expected = '<img src="https://example.com/example.png" onload=\'testFunc("test")\'>';
401+
402+
fs.writeFileSync('test.html', render(fixture, options));
403+
expect(render(fixture, options)).to.eql(expected);
404+
});
405+
});
374406
});
375407
});

0 commit comments

Comments
 (0)