|  | 
| 1 | 1 | /* global Asciidoctor */ | 
| 2 | 2 | import Asciidoctor from '../../build/asciidoctor-quickjs.js' | 
| 3 |  | -const asciidoctor = Asciidoctor() | 
|  | 3 | +// poor man mocha since QuickJS don't rely on NPM | 
|  | 4 | +const expect = (obj) => ({to:{include(str){if(!obj.includes(str))throw `${obj} does not contain ${str}`}}}); | 
|  | 5 | +const describe = (title, todo) => todo(console.log(`${title}`)); | 
|  | 6 | +const it = (title, todo) => todo(console.log(`  ${title}`)); | 
| 4 | 7 | 
 | 
|  | 8 | +const asciidoctor = Asciidoctor() | 
| 5 | 9 | const data = '= asciidoctor.js, AsciiDoc in JavaScript\n' + | 
| 6 |  | -'Doc Writer <[email protected]>\n\n' + | 
| 7 |  | -'Asciidoctor and Opal come together to bring\n' + | 
| 8 |  | -'http://asciidoc.org[AsciiDoc] to the browser!.\n\n' + | 
| 9 |  | -'== Technologies\n\n' + | 
| 10 |  | -'* AsciiDoc\n' + | 
| 11 |  | -'* Asciidoctor\n' + | 
| 12 |  | -'* Opal\n\n' + | 
| 13 |  | -'NOTE: That\'s all she wrote!!!\n\n' + | 
| 14 |  | -'include::spec/fixtures/include.adoc[]' | 
|  | 10 | +	'Doc Writer <[email protected]>\n\n' + | 
|  | 11 | +	'Asciidoctor and Opal come together to bring\n' + | 
|  | 12 | +	'http://asciidoc.org[AsciiDoc] to the browser!.\n\n' + | 
|  | 13 | +	'== Technologies\n\n' + | 
|  | 14 | +	'* AsciiDoc\n' + | 
|  | 15 | +	'* Asciidoctor\n' + | 
|  | 16 | +	'* Opal\n\n' + | 
|  | 17 | +	'NOTE: That\'s all she wrote!!!\n\n' | 
| 15 | 18 | 
 | 
| 16 |  | -const options = { safe: 0, header_footer: true, attributes: { stylesheet: "spec/fixtures/css/simple.css", showtitle: true } } | 
| 17 |  | -const html = asciidoctor.convert(data, options) | 
| 18 |  | -console.log(html) | 
|  | 19 | +describe('QuickJS', function () { | 
|  | 20 | +	it('should convert as HTML', function () { | 
|  | 21 | +		const opts = { } | 
|  | 22 | +		const html = asciidoctor.convert(data, opts); | 
|  | 23 | +		expect(html).to.include('<ul>'); | 
|  | 24 | +	}) | 
|  | 25 | +	it('should include stylesheet', function () { | 
|  | 26 | +		const opts = { safe: 0, header_footer: true, attributes: { stylesheet: "spec/fixtures/css/simple.css", showtitle: true } }; | 
|  | 27 | +		const html = asciidoctor.convert(data, opts); | 
|  | 28 | +		expect(html).to.include('4078c0'); | 
|  | 29 | +	}) | 
|  | 30 | +	it('should include file', function () { | 
|  | 31 | +		const opts = { safe: 0 }; | 
|  | 32 | +		const html = asciidoctor.convert('include::spec/fixtures/include.adoc[]', opts) | 
|  | 33 | +		expect(html).to.include('include content'); | 
|  | 34 | +	}) | 
|  | 35 | +}) | 
0 commit comments