<commit_before>describe('su-modal', function () {
  let tag
  let spyOnShow = sinon.spy()
  let spyOnHide = sinon.spy()
  let mount = opts => {
    tag = riot.mount('su-modal', opts)[0]
    tag.on('show', spyOnShow)
      .on('hide', spyOnHide)
  }

  beforeEach(function () {
    this.clock = sinon.useFakeTimers()
  })

  afterEach(function () {
    spyOnShow.reset()
    spyOnHide.reset()
    this.clock.restore()
    tag.unmount()
  })

  it('is mounted', function () {
    $('body').append('<su-modal>modal</su-modal>')
    mount()
    tag.isMounted.should.be.true
  })

  it('opens/closes modal and triggers open/close event', function () {
    $('body').append('<su-modal>modal</su-modal>')
    mount({
      modal: {
        buttons: [{
          text: 'Ok',
        }]
      }
    })
    $('su-modal').is(':visible').should.equal(false)

    tag.show()
    spyOnShow.should.have.been.calledOnce
    this.clock.tick(510)
    $('su-modal').is(':visible').should.equal(true)

    $('su-modal .ui.button:first').click()
    spyOnHide.should.have.been.calledOnce
    this.clock.tick(310)
    $('su-modal').is(':visible').should.equal(false)
  })

  it('dimmer close', function () {
    $('body').append('<su-modal>modal</su-modal>')
    mount()
    $('su-modal').is(':visible').should.equal(false)

    tag.show()
    spyOnShow.should.have.been.calledOnce
    this.clock.tick(510)
    $('su-modal').is(':visible').should.equal(true)

    $('su-modal').click()
    spyOnHide.should.have.been.calledOnce
    this.clock.tick(310)
    $('su-modal').is(':visible').should.equal(false)
  })

  it('buttons', function () {
    $('body').append('<su-modal>modal</su-modal>')
    const modal = {
      buttons: [{
        text: 'Ok',
        type: 'primary',
        icon: 'checkmark'
      }, {
        text: 'Cancel'
      }]
    }<commit_msg>Add test for su-modal<commit_after>describe('su-modal', function () {
  let tag
  let spyOnShow = sinon.spy()
  let spyOnHide = sinon.spy()
  let mount = opts => {
    tag = riot.mount('su-modal', opts)[0]
    tag.on('show', spyOnShow)
      .on('hide', spyOnHide)
  }

  beforeEach(function () {
    this.clock = sinon.useFakeTimers()
  })

  afterEach(function () {
    spyOnShow.reset()
    spyOnHide.reset()
    this.clock.restore()
    tag.unmount()
  })

  it('is mounted', function () {
    $('body').append('<su-modal>modal</su-modal>')
    mount()
    tag.isMounted.should.be.true
  })

  it('opens/closes modal and triggers open/close event', function () {
    $('body').append('<su-modal>modal</su-modal>')
    mount({
      modal: {
        buttons: [{
          text: 'Ok',
        }]
      }
    })
    $('su-modal').is(':visible').should.equal(false)

    tag.show()
    spyOnShow.should.have.been.calledOnce
    this.clock.tick(510)
    $('su-modal').is(':visible').should.equal(true)

    $('su-modal .ui.button:first').click()
    spyOnHide.should.have.been.calledOnce
    this.clock.tick(310)
    $('su-modal').is(':visible').should.equal(false)
  })

  it('dimmer close', function () {
    $('body').append('<su-modal>modal</su-modal>')
    mount()
    $('su-modal').is(':visible').should.equal(false)

    tag.show()
    spyOnShow.should.have.been.calledOnce
    this.clock.tick(510)
    $('su-modal').is(':visible').should.equal(true)

    $('su-modal').click()
    spyOnHide.should.have.been.calledOnce
    this.clock.tick(310)
    $('su-modal').is(':visible').should.equal(false)
  })

  it('opens/closes event duplicate', function () {
    $('body').append('<su-modal>modal</su-modal>')
    mount({
      modal: {
        buttons: [{
          text: 'Ok',
          closable: true
        }]
      }
    })
    $('su-modal').is(':visible').should.equal(false)

    tag.show()
    tag.show()
    spyOnShow.should.have.been.calledOnce
    this.clock.tick(510)
    $('su-modal').is(':visible').should.equal(true)

    $('su-modal .ui.button:first').click()
    $('su-modal .ui.button:first').click()
    spyOnHide.should.have.been.calledOnce
    this.clock.tick(310)
    $('su-modal').is(':visible').should.equal(false)
  })

  it('buttons', function () {
    $('body').append('<su-modal>modal</su-modal>')
    const modal = {
      buttons: [{
        text: 'Ok',
        type: 'primary',
        icon: 'checkmark'
      }, {
        text: 'Cancel'
      }]
    }
{'fraction_non_alphanumeric': 0.20966250577901063, 'fraction_numerical': 0.007397133610725843, 'mean_word_length': 2.673174872665535, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, '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': '4647640', 'n_tokens_mistral': 1585, 'n_tokens_neox': 1533, 'n_words': 198}