<commit_before>{RootView} = require 'atom'
GoToLineView = require '../lib/go-to-line-view'

describe 'GoToLine', ->
  [goToLine, editor] = []

  beforeEach ->
    window.rootView = new RootView
    rootView.open('sample.js')
    rootView.enableKeymap()
    editor = rootView.getActiveView()
    goToLine = GoToLineView.activate()
    editor.setCursorBufferPosition([1,0])

  describe "when editor:go-to-line is triggered", ->
    it "attaches to the root view", ->
      expect(goToLine.hasParent()).toBeFalsy()
      editor.trigger 'editor:go-to-line'
      expect(goToLine.hasParent()).toBeTruthy()

  describe "when entering a line number", ->
    it "only allows 0-9 to be entered in the mini editor", ->
      expect(goToLine.miniEditor.getText()).toBe ''
      goToLine.miniEditor.textInput 'a'
      expect(goToLine.miniEditor.getText()).toBe ''
      goToLine.miniEditor.textInput '40'
      expect(goToLine.miniEditor.getText()).toBe '40'

  describe "when core:confirm is triggered", ->
    describe "when a line number has been entered", ->
      it "moves the cursor to the first character of the line", ->
        goToLine.miniEditor.textInput '3'
        goToLine.miniEditor.trigger 'core:confirm'
        expect(editor.getCursorBufferPosition()).toEqual [2, 4]

    describe "when no line number has been entered", ->
      it "closes the view and does not update the cursor position", ->
        editor.trigger 'editor:go-to-line'
        expect(goToLine.hasParent()).toBeTruthy()
        goToLine.miniEditor.trigger 'core:confirm'<commit_msg>Use RootView::openSync in specs<commit_after>{RootView} = require 'atom'
GoToLineView = require '../lib/go-to-line-view'

describe 'GoToLine', ->
  [goToLine, editor] = []

  beforeEach ->
    window.rootView = new RootView
    rootView.openSync('sample.js')
    rootView.enableKeymap()
    editor = rootView.getActiveView()
    goToLine = GoToLineView.activate()
    editor.setCursorBufferPosition([1,0])

  describe "when editor:go-to-line is triggered", ->
    it "attaches to the root view", ->
      expect(goToLine.hasParent()).toBeFalsy()
      editor.trigger 'editor:go-to-line'
      expect(goToLine.hasParent()).toBeTruthy()

  describe "when entering a line number", ->
    it "only allows 0-9 to be entered in the mini editor", ->
      expect(goToLine.miniEditor.getText()).toBe ''
      goToLine.miniEditor.textInput 'a'
      expect(goToLine.miniEditor.getText()).toBe ''
      goToLine.miniEditor.textInput '40'
      expect(goToLine.miniEditor.getText()).toBe '40'

  describe "when core:confirm is triggered", ->
    describe "when a line number has been entered", ->
      it "moves the cursor to the first character of the line", ->
        goToLine.miniEditor.textInput '3'
        goToLine.miniEditor.trigger 'core:confirm'
        expect(editor.getCursorBufferPosition()).toEqual [2, 4]

    describe "when no line number has been entered", ->
      it "closes the view and does not update the cursor position", ->
        editor.trigger 'editor:go-to-line'
        expect(goToLine.hasParent()).toBeTruthy()
        goToLine.miniEditor.trigger 'core:confirm'
{'fraction_non_alphanumeric': 0.12802547770700637, 'fraction_numerical': 0.0070063694267515925, 'mean_word_length': 3.338397790055249, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2732537', 'n_tokens_mistral': 982, 'n_tokens_neox': 946, 'n_words': 234}