diff --git a/spec/indentation-spec.js b/spec/indentation-spec.js index 694b47af..b85dd700 100644 --- a/spec/indentation-spec.js +++ b/spec/indentation-spec.js @@ -29,7 +29,7 @@ expect(parseInt($p1.css('margin-left'))).toBe(0); return expect(parseInt($p2.css('margin-left'))).toBe(0); }); - return it('should indent list when pressing tab in ul', function() { + it('should indent list when pressing tab in ul', function() { var $li, $li1, $li2, $ul, range; editor = spec.generateSimditor({ content: '' @@ -52,6 +52,20 @@ expect($li1.parentsUntil(editor.body, 'ul').length).toBe(1); return expect($li2.parentsUntil(editor.body, 'ul').length).toBe(1); }); + return it('should insert two spaces while pressing tab in code block', function() { + var $pre, range; + editor = spec.generateSimditor({ + content: '
var test = 1;
', + toolbar: ['code'] + }); + editor.focus(); + $pre = editor.body.find('> pre'); + range = document.createRange(); + editor.selection.setRangeAtStartOf($pre, range); + expect($pre.html()).toBe('var test = 1;'); + editor.indentation.indent(); + return expect($pre.html()).toBe('  var test = 1;'); + }); }); }).call(this); diff --git a/spec/src/indentation-spec.coffee b/spec/src/indentation-spec.coffee index a727a3b0..09cc7f3b 100644 --- a/spec/src/indentation-spec.coffee +++ b/spec/src/indentation-spec.coffee @@ -59,3 +59,19 @@ describe 'A Simditor instance with indentation manager', -> editor.indentation.indent(true) expect($li1.parentsUntil(editor.body, 'ul').length).toBe(1) expect($li2.parentsUntil(editor.body, 'ul').length).toBe(1) + + it 'should insert two spaces while pressing tab in code block', -> + editor = spec.generateSimditor + content: ''' +
var test = 1;
+ ''' + toolbar: ['code'] + editor.focus() + + $pre = editor.body.find '> pre' + range = document.createRange() + editor.selection.setRangeAtStartOf $pre, range + + expect($pre.html()).toBe('var test = 1;') + editor.indentation.indent() + expect($pre.html()).toBe('  var test = 1;')