import fs from 'fs';
import test from 'ava';
import m from './';

test('valid SVGs', t => {
	t.true(m(fs.readFileSync('fixtures/fixture.svg')));
	t.true(m('<svg width="100" height="100" viewBox="0 0 30 30" version="1.1"></svg>'));
	t.true(m('<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg></svg>'));
	t.true(m('<?xml version="1.0" standalone="no"?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n<svg></svg>'));
	t.true(m('<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">]><svg></svg>'));
	t.true(m('<svg></svg>    '));
	t.true(m('    <svg></svg>'));
	t.true(m('<svg>\n</svg>'));
	t.true(m('<!--unicorn--><svg>\n</svg><!--cake-->'));
});

test('invalid SVGs', t => {
	t.false(m(fs.readFileSync('fixtures/fixture.jpg')));
	t.false(m('this is not svg, but it mentions <svg> tags'));
	t.false(m('<svg> hello I am an svg oops maybe not'));
	t.false(m('<svg></svg> this string starts with an svg'));
	t.false(m('this string ends with an svg <svg></svg>'));
	t.false(m('<div><svg></svg>'));
	t.false(m('<div><svg></svg></div>'));
	t.false(m('this string contains an svg <svg></svg> in the middle'));
	t.false(m(fs.readFileSync('readme.md')));
	t.false(m(fs.readFileSync('index.js')));
});

@@ -1455,16 +1455,545 @@
 dex.js')));%0A%7D);%0A
+%0Atest('supports non-english characters', t =%3E %7B%0A%09t.true(m(%60%3Csvg xmlns=%22http://www.w3.org/2000/svg%22%0A%09     width=%22100%25%22 height=%22100%25%22 viewBox=%220 0 400 400%22%0A%09     direction=%22rtl%22 xml:lang=%22fa%22%3E%0A%0A%09  %3Ctitle direction=%22ltr%22 xml:lang=%22en%22%3ERight-to-left Text%3C/title%3E%0A%09  %3Cdesc direction=%22ltr%22 xml:lang=%22en%22%3E%0A%09    A simple example for using the 'direction' property in documents%0A%09    that predominantly use right-to-left languages.%0A%09  %3C/desc%3E%0A%0A%09  %3Ctext x=%22200%22 y=%22200%22 font-size=%2220%22%3E%D8%AF%D8%A7%D8%B3%D8%AA%D8%A7%D9%86 SVG 1.1 SE %D8%B7%D9%88%D9%84%D8%A7 %D9%86%D9%8A %D8%A7%D8%B3%D8%AA.%3C/text%3E%0A%0A%09%3C/svg%3E%60));%0A%7D);%0A

Add test for non-english characters