<commit_before>MinimapFindAndReplace = require '../lib/minimap-find-and-replace'
{WorkspaceView} = require 'atom'

describe "MinimapFindAndReplace", ->
  beforeEach ->
    runs ->
      atom.workspaceView = new WorkspaceView
      atom.workspaceView.openSync('sample.js')

    runs ->
      atom.workspaceView.attachToDom()
      editorView = atom.workspaceView.getActiveView()
      editorView.setText("This is the file content")

    waitsForPromise ->
      promise = atom.packages.activatePackage('minimap')
      atom.workspaceView.trigger 'minimap:toggle'
      promise

    waitsForPromise ->
      promise = atom.packages.activatePackage('find-and-replace')
      atom.workspaceView.trigger 'find-and-replace:show'
      promise

  describe "when the toggle event is triggered", ->
    beforeEach ->
      waitsForPromise ->
        promise = atom.packages.activatePackage('minimap-find-and-replace')
        atom.workspaceView.trigger 'minimap-find-and-replace:toggle'
        promise

    it 'should exist', ->
      expect()<commit_msg>add tests<commit_after>MinimapFindAndReplace = require '../lib/minimap-find-and-replace'

describe 'MinimapFindAndReplace', ->
  [workspace] = []

  beforeEach ->
    workspace = atom.views.getView(atom.workspace)
    jasmine.attachToDOM(workspace)

    waitsForPromise ->
      atom.packages.activatePackage('minimap')

    waitsForPromise ->
      promise = atom.packages.activatePackage('find-and-replace')
      atom.commands.dispatch(workspace, 'find-and-replace:show')
      promise

  describe 'when the package is activated', ->
    beforeEach ->
      waitsForPromise -> atom.packages.activatePackage('minimap-find-and-replace')

    it 'should activate', ->
      expect(MinimapFindAndReplace.isActive()).toBe(true)

    describe 'when find-and-replace is closed', ->
      beforeEach ->
        atom.commands.dispatch(workspace, 'find-and-replace:show')
        spyOn(MinimapFindAndReplace, "clearBindings")

      it "should clear on core:cancel", ->
        atom.commands.dispatch(workspace, "core:cancel")
        expect(MinimapFindAndReplace.clearBindings.calls.length).toBe(1)

      it "should clear on find-and-replace:toggle", ->
        atom.commands.dispatch(workspace, "find-and-replace:toggle")
        atom.commands.dispatch(workspace, "find-and-replace:toggle")
        expect(MinimapFindAndReplace.clearBindings.calls.length).toBe(1)

      it "should clear on close button pressed", ->
        document.querySelector(".find-and-replace .close-button").click()
        expect(MinimapFindAndReplace.clearBindings.calls.length).toBe(1)

    describe 'when find-and-replace is opened', ->
      beforeEach ->
        atom.commands.dispatch(workspace, 'core:cancel')
        spyOn(MinimapFindAndReplace, "discoverMarkers")

      it "should display markers on find-and-replace:show", ->
        atom.commands.dispatch(workspace, "find-and-replace:show")
        expect(MinimapFindAndReplace.discoverMarkers.calls.length).toBe(1)

      it "should display markers on find-and-replace:show-replace", ->
        atom.commands.dispatch(workspace, "find-and-replace:show-replace")
        expect(MinimapFindAndReplace.discoverMarkers.calls.length).toBe(1)

      it "should display markers on find-and-replace:toggle", ->
        atom.commands.dispatch(workspace, "find-and-replace:toggle")
        expect(MinimapFindAndReplace.discoverMarkers.calls.length).toBe(1)
{'fraction_non_alphanumeric': 0.12306794983960338, 'fraction_numerical': 0.0017497812773403325, 'mean_word_length': 3.4315245478036176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '1071701', 'n_tokens_mistral': 1019, 'n_tokens_neox': 1015, 'n_words': 159}