HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/quadcode-jobs/node_modules/intl-tel-input/src/spec/tests/options/dropdownContainer.js
"use strict";

describe("dropdownContainer:", function() {

  beforeEach(function() {
    intlSetup();
    // insert input into the DOM so our visibility tests will work
    input = $("<input>").appendTo("body");
  });

  afterEach(function() {
    intlTeardown();
  });

  describe("init plugin with dropdownContainer=null", function() {

    beforeEach(function() {
      iti = window.intlTelInput(input[0], {
        dropdownContainer: null,
      });
    });

    it("adds the dropdown markup next to the input", function() {
      expect(getListElement()).toExist();
    });

    describe("clicking the selected flag", function() {

      beforeEach(function() {
        getSelectedFlagContainer().click();
      });

      it("shows the dropdown", function() {
        expect(getListElement()).toBeVisible();
      });

      it("clicking-off removes the markup again", function() {
        $("body").click();
        expect(getListElement()).not.toBeVisible();
      });

    });

  });

  describe("init plugin with dropdownContainer=document.body", function() {

    beforeEach(function() {
      iti = window.intlTelInput(input[0], {
        dropdownContainer: document.body,
      });
    });

    it("doesnt immediately add the markup to the DOM", function() {
      expect($(".iti--container")).not.toExist();
    });

    describe("triggering the dropdown", function() {

      beforeEach(function() {
        getSelectedFlagContainer().click();
      });

      it("adds the markup to that element and makes it visible in the document", function() {
        expect($("body>.iti--container")).toBeVisible();
      });

      it("selecting a country removes the markup again", function() {
        $("body>.iti--container").find("li[data-country-code='gb']").click();
        expect($("body>.iti--container")).not.toExist();
      });

      it("clicking-off removes the markup again", function() {
        $("body").click();
        expect($("body>.iti--container")).not.toExist();
      });

    });

  });

});