';
442 |
443 | t.is(render(fixture, options), expected);
444 | });
445 |
446 | test('{Options} {quoteAllAttributes} True', t => {
447 | const options = {quoteAllAttributes: true};
448 |
449 | const fixture = {tag: 'a', attrs: {href: '/about/me/'}};
450 | const expected = '
';
451 |
452 | t.is(render(fixture, options), expected);
453 | });
454 |
455 | test('{Options} {quoteAllAttributes} False', t => {
456 | const options = {quoteAllAttributes: false};
457 |
458 | const fixture = {tag: 'a', attrs: {href: '/about/me/'}};
459 | const expected = '
';
460 |
461 | t.is(render(fixture, options), expected);
462 | });
463 |
464 | test('{Options} {quoteAllAttributes} Required Space', t => {
465 | const options = {quoteAllAttributes: false};
466 |
467 | const fixture = {tag: 'p', attrs: {id: 'asd adsasd'}};
468 | const expected = '
';
469 |
470 | t.is(render(fixture, options), expected);
471 | });
472 |
473 | test('{Options} {quoteAllAttributes} Required Tab', t => {
474 | const options = {quoteAllAttributes: false};
475 |
476 | const fixture = {tag: 'a', attrs: {href: '/about-\t-characters'}};
477 | const expected = '
';
478 |
479 | t.is(render(fixture, options), expected);
480 | });
481 |
482 | test('{Options} {quoteAllAttributes} Required Empty', t => {
483 | const options = {quoteAllAttributes: false};
484 |
485 | const fixture = {tag: 'script', attrs: {async: ''}};
486 | const expected = '';
487 |
488 | t.is(render(fixture, options), expected);
489 | });
490 |
491 | test('{Options} {quoteAllAttributes} Closing slash', t => {
492 | const options = {
493 | closingSingleTag: closingSingleTagOptionEnum.slash,
494 | quoteAllAttributes: false,
495 | };
496 |
497 | // Note that
is incorrect as that is parsed as
498 | //
.
499 |
500 | const fixture = {tag: 'area', attrs: {href: 'foobar'}};
501 | const expected = '
';
502 |
503 | t.is(render(fixture, options), expected);
504 | });
505 |
506 | test('{Options} {replaceQuote} replace quote', t => {
507 | const options = {replaceQuote: false};
508 |
509 | const fixture = {tag: 'img', attrs: {src: ''}};
510 | const expected = '

">';
511 | t.is(render(fixture, options), expected);
512 | });
513 |
514 | test('{Options} {replaceQuote} replace quote ternary operator', t => {
515 | const options = {replaceQuote: false};
516 |
517 | const fixture = {tag: 'img', attrs: {src: ''}};
518 | const expected = '

">';
519 | t.is(render(fixture, options), expected);
520 | });
521 |
522 | test('{Options} {quoteStyle} 1 - single quote', t => {
523 | const options = {replaceQuote: false, quoteStyle: quoteStyleEnum.Single};
524 |
525 | const fixture = {tag: 'img', attrs: {src: 'https://example.com/example.png', onload: 'testFunc("test")'}};
526 | const expected = '

';
527 |
528 | t.is(render(fixture, options), expected);
529 | });
530 |
531 | test('{Options} {quoteStyle} 2 - double quote', t => {
532 | const options = {replaceQuote: false, quoteStyle: quoteStyleEnum.Double};
533 |
534 | const fixture = {tag: 'img', attrs: {src: 'https://example.com/example.png', onload: 'testFunc("test")'}};
535 | const expected = '

';
536 |
537 | t.is(render(fixture, options), expected);
538 | });
539 |
540 | test('{Options} {quoteStyle} 0 - smart quote', t => {
541 | const options = {replaceQuote: false, quoteStyle: quoteStyleEnum.Smart};
542 |
543 | const fixture = {tag: 'img', attrs: {src: 'https://example.com/example.png', onload: 'testFunc("test")'}};
544 | const expected = '

';
545 |
546 | t.is(render(fixture, options), expected);
547 | });
548 |
549 | test('{QuoteStyle} for width/height attrs in img', t => {
550 | const fixture = {
551 | tag: 'img',
552 | attrs: {
553 | src: 'https://example.com/example.png',
554 | width: '20',
555 | height: '20',
556 | },
557 | };
558 | const expected = '

';
559 |
560 | t.is(render(fixture), expected);
561 | });
562 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "lib": ["ESNext"],
5 | "esModuleInterop": true,
6 | "moduleResolution": "node",
7 | "strict": true,
8 | "strictNullChecks": true,
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/xo.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | space: true,
3 | ignores: ['test/render.test.js'],
4 | rules: {
5 | 'ava/no-import-test-files': 'off',
6 | 'unicorn/prefer-node-protocol': 'off',
7 | '@typescript-eslint/no-unsafe-call': 'off',
8 | '@typescript-eslint/restrict-template-expressions': 'off',
9 | 'import/extensions': 'off',
10 | 'ava/no-skip-test': 'off',
11 | 'ava/no-only-test': 'off',
12 | 'unicorn/prefer-module': 'off',
13 | },
14 | };
15 |
--------------------------------------------------------------------------------