surveybuilder
Version:
Build surveys in the most advanced, flexable, and more moderated way, for all users to build and see.
42 lines (31 loc) • 1.07 kB
text/coffeescript
describe '#getPosBegninningOfLines', ->
textarea = null
action = null
selectionStart = null
selectionEnd = null
markdownEditor = null
beforeEach ->
textarea = $('<textarea>').markdownEditor()
markdownEditor = textarea.data('markdownEditor')
textarea.val("abc\ndef\nfgh")
action = ->
markdownEditor.getSelectionStart = -> selectionStart
markdownEditor.getSelectionEnd = -> selectionEnd
markdownEditor.getPosBeginningOfLines(markdownEditor.getText())
context 'no selection range', ->
context 'middle position of line', ->
beforeEach ->
selectionStart = selectionEnd = 1
it 'get one', ->
expect(action()).to.eql [0]
context 'beginning of second line', ->
beforeEach ->
selectionStart = selectionEnd = 4
it 'get one', ->
expect(action()).to.eql [4]
context 'selection range', ->
beforeEach ->
selectionStart = 1
selectionEnd = 8
it 'get three', ->
expect(action()).to.eql [0, 4, 8]