(function() { describe('Simditor Formatter Module', function() { var editor; editor = null; beforeEach(function() { return editor = spec.generateSimditor(); }); afterEach(function() { spec.destroySimditor(); return editor = null; }); it('can convert url string to anchor element', function() { var $p1, $p2, $p3; $p1 = editor.formatter.autolink($('

http://test.com?x=1

')); $p2 = editor.formatter.autolink($('

http://www.test.net?x=1&y=2

')); $p3 = editor.formatter.autolink($('

http://127.0.0.1:3000/test

')); expect($p1.html()).toBe('http://test.com?x=1'); expect($p2.html()).toBe('http://www.test.net?x=1&y=2'); return expect($p3.html()).toBe('http://127.0.0.1:3000/test'); }); it('can clean forbidden tags and attributes and modify redundancy tags', function() { var $p1, $p2, $p3, $p4, $p5, $p6; $p1 = $('

\r\nthis is a test

'); $p2 = $('

this is a test

'); $p3 = $('
'); $p4 = $('
'); $p5 = $('
testImage
'); $p6 = $('
'); editor.formatter.cleanNode($p1.contents(), true); editor.formatter.cleanNode($p2.contents(), true); editor.formatter.cleanNode($p3.contents(), true); editor.formatter.cleanNode($p4.contents(), true); editor.formatter.cleanNode($p5.contents(), true); editor.formatter.cleanNode($p6.contents(), true); expect($p1.html()).toBe('

this is a test

'); expect($p2.html()).toBe('

this is a test

'); expect($p3.html()).toBe('var x = 1;'); expect($p4.html()).toBe(''); expect($p5.html()).toBe('testImage'); return expect($p6.html()).toBe(''); }); it('can format all direct children to block node', function() { var $p1, $p2, $p3, $p4; $p1 = editor.formatter.format($('

')); $p2 = editor.formatter.format($('
test
')); $p3 = editor.formatter.format($('
  • list-item-1
  • ')); $p4 = editor.formatter.format($('
  • list-item-1
  • list-item-2
  • ')); expect($p1.html()).toBe(''); expect($p2.html()).toBe('

    test

    '); expect($p3.html()).toBe(''); return expect($p4.html()).toBe(''); }); it('can clean html tag', function() { var $p1, $p2; $p1 = editor.formatter.clearHtml('

    this is

    test

    '); $p2 = editor.formatter.clearHtml('

    this is

    test

    ', false); expect($p1).toBe('this is\ntest'); return expect($p2).toBe('this is test'); }); return it('can remove empty nodes and useless paragraph', function() { var $p1, $p2; $p1 = $('

    this is test


    '); $p2 = $('


    '); editor.formatter.beautify($p1); editor.formatter.beautify($p2); expect($p1.html()).toBe('

    this is test


    '); return expect($p2.html()).toBe('

    '); }); }); }).call(this);