import { prettifySVG } from '../lib/svg/pretty'; describe('Prettify SVG', () => { test('Basic XML', () => { expect( prettifySVG( '' ) ).toBe( '\n\t\n\t\n\n' ); // Self closing tag expect( prettifySVG( '' ) ).toBe( '\n\t\n\n' ); // With xml tag expect( prettifySVG( '\n\n\n\n\t' ) ).toBe( '\n\n\t\n\n' ); }); test('Text', () => { expect(prettifySVG('Trimmed Text')).toBe( '\n\tTrimmed Text\n\n' ); expect( prettifySVG(' Right Trimmed Text') ).toBe('\n\t Right Trimmed Text\n\n'); expect( prettifySVG('Left Trimmed Text ') ).toBe('\n\tLeft Trimmed Text \n\n'); expect(prettifySVG(' Text ')).toBe( '\n\t\n\t\tText\n\t\n\n' ); }); test('Style and script', () => { // Basic CSS expect( prettifySVG('') ).toBe('\n\t\n\n'); // Basic script expect( prettifySVG( '' ) ).toBe( '\n\t\n\n' ); // Selector with '>' and tag after that expect( prettifySVG( '' ) ).toBe( '\n\t\n\t\n\t\n\n' ); }); test('Bad code', () => { expect(prettifySVG('Incomplete SVG')).toBeNull(); expect( prettifySVG('Incomplete SVG/svg>') ).toBeNull(); expect( prettifySVG('Incomplete SVG') ).toBeNull(); expect( prettifySVG('Unescaped < text') ).toBeNull(); expect( prettifySVG('Unescaped > text') ).toBeNull(); expect( prettifySVG('Unescaped attr') ).toBeNull(); expect( prettifySVG('Unescaped attr') ).toBeNull(); }); });