/* jshint expr:true */ import {expect} from 'chai'; import {describe, it} from 'mocha'; import {setupComponentTest} from 'ember-mocha'; import hbs from 'htmlbars-inline-precompile'; import {editorRendered, testInput} from '../../helpers/editor-helpers'; describe('Integration: Component: gh-koenig', function () { setupComponentTest('gh-koenig', { integration: true }); describe('Makerable markdown support.', function() { it('plain text inputs (placebo)', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('abcdef', '
abcdef
', expect); }) .then(() => { done(); }); }); // bold it('** bolds at start of line', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('**test**', 'test
', expect); }) .then(() => { done(); }); }); it('** bolds in a line', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('123**test**', '123test
', expect); }) .then(() => { done(); }); }); it('__ bolds at start of line', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('__test__', 'test
', expect); }) .then(() => { done(); }); }); it('__ bolds in a line', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('__test__', 'test
', expect); }) .then(() => { done(); }); }); // italic it('* italicises at start of line', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('*test*', 'test
', expect); }) .then(() => { done(); }); }); it('* italicises in a line', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('123*test*', '123test
', expect); }) .then(() => { done(); }); }); it('_ italicises at start of line', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('_test_', 'test
', expect); }) .then(() => { done(); }); }); it('_ italicises in a line', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('123_test_', '123test
', expect); }) .then(() => { done(); }); }); // strikethrough it('~~ strikethroughs at start of line', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('~~test~~', 'test
123test
123ghost
', expect); }) .then(() => { done(); }); }); }); describe('Block markdown support', function () { // headings it('# creates an H1', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('# ', '', expect); }) .then(() => { done(); }); }); }); describe.skip('Card markdown support.', function () { it('![]() creates an image card', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('![image of something](https://unsplash.it/200/300/?random) ', '...', expect); }) .then(() => { done(); }); }); it('``` creates a markdown card.', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('```some code``` ', '...', expect); }) .then(() => { done(); }); }); }); });