{"size": 1657, "ext": "js", "max_stars_repo_path": "admin/sweetalert2-master/cypress/integration/params/allowOutsideClick.spec.js", "max_stars_repo_name": "jaurecito23/gdlwebcam", "max_stars_repo_stars_event_min_datetime": "2018-01-05T13:04:43.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T23:22:34.000Z", "max_issues_repo_path": "admin/sweetalert2-master/cypress/integration/params/allowOutsideClick.spec.js", "max_issues_repo_name": "jaurecito23/gdlwebcam", "max_issues_repo_issues_event_min_datetime": "2018-01-05T12:04:34.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T16:34:40.000Z", "max_forks_repo_path": "admin/sweetalert2-master/cypress/integration/params/allowOutsideClick.spec.js", "max_forks_repo_name": "jaurecito23/gdlwebcam", "max_forks_repo_forks_event_min_datetime": "2018-01-05T12:11:43.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-26T20:03:34.000Z"}
{"max_stars_count": 10915, "max_issues_count": 1554, "max_forks_count": 1142, "avg_line_length": 29.5892857143, "max_line_length": 133, "alphanum_fraction": 0.6143633072}
import { Swal, SwalWithoutAnimation, TIMEOUT } from '../../utils'

describe('allowOutsideClick', () => {
  it('allowOutsideClick: false', (done) => {
    SwalWithoutAnimation.fire({
      title: 'allowOutsideClick: false',
      allowOutsideClick: false
    })
    Swal.getContainer().click()
    setTimeout(() => {
      expect(Swal.isVisible()).to.be.true
      done()
    })
  })

  it('allowOutsideClick: () => !swal.isLoading()', (done) => {
    SwalWithoutAnimation.fire({
      title: 'allowOutsideClick: () => !swal.isLoading()',
      allowOutsideClick: () => !Swal.isLoading()
    }).then((result) => {
      expect(result).to.eql({
        dismiss: Swal.DismissReason.backdrop,
        isConfirmed: false,
        isDenied: false,
        isDismissed: true,
      })
      done()
    })
    Swal.showLoading()
    Swal.getContainer().click()
    setTimeout(() => {
      expect(Swal.isVisible()).to.be.true
      Swal.hideLoading()
      Swal.getContainer().click()
    }, TIMEOUT)
  })

  it('should throw console warning for { backdrop: false, allowOutsideClick: true }', () => {
    const spy = cy.spy(console, 'warn')
    SwalWithoutAnimation.fire({
      title: 'allowOutsideClick is not compatible with modeless popups',
      allowOutsideClick: true,
      backdrop: false
    })
    expect(spy.calledWith('SweetAlert2: "allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`')).to.be.true
  })

  it('should not throw console warning for { backdrop: false }', () => {
    const spy = cy.spy(console, 'warn')
    SwalWithoutAnimation.fire({
      backdrop: false
    })
    expect(spy.notCalled).to.be.true
  })
})
