/* 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, testInputTimeout} from '../../helpers/editor-helpers'; describe('Integration: Component: gh-koenig', function () { setupComponentTest('gh-koenig', { integration: true }); beforeEach(function () { this.set('value', { version: '0.3.1', atoms: [], markups: [], cards: [], sections: []}); }); describe('Makerable markdown support.', function() { it('plain text inputs (placebo)', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' value=value }}`); 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' value=value }}`); 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' value=value }}`); 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' value=value }}`); 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' value=value }}`); 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' value=value }}`); 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' value=value }}`); 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' value=value }}`); 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' value=value }}`); 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' value=value }}`); 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' value=value }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInput('# ', '', expect); }) .then(() => { done(); }); }); }); describe('Card markdown support.', function () { it('![]() creates an image card', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' value=value }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInputTimeout('![image of something](https://unsplash.it/200/300/?random)'); }) .then((value) => { expect(value).to.have.string('kg-card-image'); done(); }); }); it('``` creates a markdown card.', function (done) { this.render(hbs`{{gh-koenig apiRoot='/todo' assetPath='/assets' containerSelector='.editor-holder' value=value }}`); editorRendered() .then(() => { let {editor} = window; editor.element.focus(); return testInputTimeout('```some code```'); }) .then((value) => { expect(value).to.have.string('kg-card-markdown'); done(); }); }); }); });