<commit_before>should = require 'should'
sinon = require 'sinon'
shouldSinon = require 'should-sinon'
KDButtonViewWithMenu = require '../../../lib/components/buttons/buttonviewwithmenu'
_ = require 'lodash'


describe 'KDButtonViewWithMenu', ->
  beforeEach ->
    @view = new KDButtonViewWithMenu
      title : 'Settings'
      iconClass : 'settings'
      cssClass : 'settings-menu'
      menu :
        'Add Into' : { callback: => (->) }
        'Edit' : { callback: => (->) }
        'Delete' : { callback: => (->) }

  describe 'constructor', ->
    it 'should instantiate without any errors', ->
      @view.should.exist

  describe 'setDomElement', ->
    it 'should set a dom element', ->
      @view.setDomElement(null).should.exist
      @view.setDomElement('koding-view').should.exist

  describe 'click', ->
    it 'should click', ->
      e = document.createEvent('MouseEvent')
      e.target = @view.domElement[0].querySelector('button')
      @view.click(e)

  describe 'setIconOnly', ->
    it 'should set icon only', ->
      @view.setIconOnly()
      @view.domElement[0].querySelector('span').className.should.equal 'icon settings'

  describe 'createContextMenu', ->
    it 'should create context menu', ->
      @view.createContextMenu()
      @view.buttonMenu.should.exist

  describe 'disable', ->
    it 'should disable', ->
      @view.disable()
      @view.domElement[0].querySelector('button').disabled.should.be.true

  describe 'enable', ->
    it 'should enable', ->
      @view.enable()
      @view.domElement[0].querySelector('button').disabled.should.be.false

  describe 'contextMenu', ->
    it 'should create context menu', ->
      @view.createContextMenu = sinon.spy (->)
      @view.contextMenu();
      @view.createContextMenu.should.be.calledOnce<commit_msg>Fix buttonviewwithmenu sinon sandbox<commit_after>should = require 'should'
sinon = require 'sinon'
shouldSinon = require 'should-sinon'
KDButtonViewWithMenu = require '../../../lib/components/buttons/buttonviewwithmenu'
_ = require 'lodash'


describe 'KDButtonViewWithMenu', ->
  beforeEach ->
    @sinon = sinon.sandbox.create()
    @view = new KDButtonViewWithMenu
      title : 'Settings'
      iconClass : 'settings'
      cssClass : 'settings-menu'
      menu :
        'Add Into' : { callback: => (->) }
        'Edit' : { callback: => (->) }
        'Delete' : { callback: => (->) }

  afterEach ->
    @sinon.restore()

  describe 'constructor', ->
    it 'should instantiate without any errors', ->
      @view.should.exist

  describe 'setDomElement', ->
    it 'should set a dom element', ->
      @view.setDomElement(null).should.exist
      @view.setDomElement('koding-view').should.exist

  describe 'click', ->
    it 'should click', ->
      e = document.createEvent('MouseEvent')
      e.target = @view.domElement[0].querySelector('button')
      @view.click(e)

  describe 'setIconOnly', ->
    it 'should set icon only', ->
      @view.setIconOnly()
      @view.domElement[0].querySelector('span').className.should.equal 'icon settings'

  describe 'createContextMenu', ->
    it 'should create context menu', ->
      @view.createContextMenu()
      @view.buttonMenu.should.exist

  describe 'disable', ->
    it 'should disable', ->
      @view.disable()
      @view.domElement[0].querySelector('button').disabled.should.be.true

  describe 'enable', ->
    it 'should enable', ->
      @view.enable()
      @view.domElement[0].querySelector('button').disabled.should.be.false

  describe 'contextMenu', ->
    it 'should create context menu', ->
      @view.createContextMenu = @sinon.stub()
      @view.contextMenu();
      @view.createContextMenu.should.be.calledOnce
{'fraction_non_alphanumeric': 0.15686805743700893, 'fraction_numerical': 0.002167434299647792, 'mean_word_length': 3.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 53, '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': '6433207', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1102, 'n_words': 222}