import test from 'ava' import Window from 'window'; import doctypeToString from '.' function makeStubDocument(doctype) { const window = new Window() const parser = new window.DOMParser() const doc = parser.parseFromString( `${doctype}`, 'text/html' ) return doc } test('should return empty string if absent', t => { const doctype = '' const doc = makeStubDocument() t.is(doctypeToString(doc.doctype), doctype) }) test('should work for a HTML5-ish doctype', t => { const doctype = '' const doc = makeStubDocument(doctype) t.is(doctypeToString(doc.doctype), doctype) }) test('should work for a HTML4-ish doctype', t => { const doctype = '' const doc = makeStubDocument(doctype) t.is(doctypeToString(doc.doctype), doctype) }) test('should work for a doctype without public id', t => { const doctype = '' const doc = makeStubDocument(doctype) t.is(doctypeToString(doc.doctype), doctype) })