module("editor"); KindEditor.ready(function (K) { var editor = K.create('#content1', { basePath : '../', filterMode : false, wellFormatMode : false }); var editor2 = K.create('#content2', { basePath : '../', filterMode : false, wellFormatMode : false }); test("K.instances", function() { ok(editor == K.instances[0]); ok(editor2 == K.instances[1]); }); test("editor.html", function() { editor.html(undefined); equals(editor.html(), ''); editor.html(null); equals(editor.html(), ''); editor.html('

abc

'); equals(editor.html(), '

abc

'); editor.html('
abc
'); equals(editor.html(), '
abc
'); editor.html(''); equals(editor.html(), ''); editor.html('
abc
'); equals(editor.html(), '
abc
'); editor.html('

abc

'); equals(editor.html(), '

abc

'); editor.html('
'); equals(editor.html(), '
'); editor.html('test'); equals(editor.html(), 'test'); editor.html('test'); equals(editor.html(), 'test'); editor.html(''); equals(editor.html(), ''); editor.html(''); equals(editor.html(), ''); editor.html('test'); equals(editor.html(), 'test'); editor.html(''); equals(editor.html(), ''); editor.html(''); equals(editor.html(), ''); editor.html(''); equals(editor.html(), ''); editor.html(''); equals(editor.html(), ''); }); test("editor.text", function() { editor.html('

abc

'); equals(editor.text(), 'abc'); editor.html('
abc
'); equals(editor.text(), 'abc'); editor.text('

'); equals(editor.text(), '<p class="a"></p>'); editor.text(''); equals(editor.text(), ''); }); test("editor.insertHtml", function() { editor.html('

abc

'); var h3 = K('#test-h3', editor.edit.doc); editor.cmd.range.selectNodeContents(h3[0]); editor.cmd.select(); editor.insertHtml('abc'); equals(editor.html(), '

abc

'); editor.html(''); }); test("editor.selectedHtml", function() { editor.html('abc'); var span = K('#test', editor.edit.doc); editor.cmd.range.setStart(span.first()[0], 0).setEnd(span.first()[0], 2); editor.cmd.select(); equals(editor.selectedHtml().replace(/<.+?>/g, ''), 'ab'); editor.html(''); }); test("editor.appendHtml", function() { editor.html(''); editor.appendHtml('

abc

'); equals(editor.html(), '

abc

'); editor.appendHtml('
abc
'); equals(editor.html(), '

abc

abc
'); editor.html(''); editor.appendHtml('abc'); equals(editor.html(), 'abc'); }); test("editor.isEmpty", function() { editor.html('

abc

'); ok(editor.isEmpty() === false); editor.html('

'); ok(editor.isEmpty() === true); editor.html(''); ok(editor.isEmpty() === false); editor.html(''); }); test("editor.count", function() { editor.html('

abc

'); ok(editor.count('html') === 12); ok(editor.count('text') === 3); editor.html('

'); ok(editor.count('html') === 9); ok(editor.count('text') === 0); editor.html(''); ok(editor.count('html') === 14); ok(editor.count('text') === 1); editor.html(''); }); });