Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gke_cluster_namespace_spec.js « gke_cluster_namespace « create_cluster « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b1c25d8fff770d6306a6b454656710aeb38876ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import initGkeNamespace from '~/create_cluster/gke_cluster_namespace';

describe('GKE cluster namespace', () => {
  const changeEvent = new Event('change');
  const isHidden = el => el.classList.contains('hidden');
  const hasDisabledInput = el => el.querySelector('input').disabled;

  let glManagedCheckbox;
  let selfManaged;
  let glManaged;

  beforeEach(() => {
    setFixtures(`
      <input class="js-gl-managed" type="checkbox" value="1" checked />
      <div class="js-namespace">
        <input type="text" />
      </div>
      <div class="js-namespace-prefixed">
        <input type="text" />
      </div>
    `);

    glManagedCheckbox = document.querySelector('.js-gl-managed');
    selfManaged = document.querySelector('.js-namespace');
    glManaged = document.querySelector('.js-namespace-prefixed');

    initGkeNamespace();
  });

  describe('GKE cluster namespace toggles', () => {
    it('initially displays the GitLab-managed label and input', () => {
      expect(isHidden(glManaged)).toEqual(false);
      expect(hasDisabledInput(glManaged)).toEqual(false);

      expect(isHidden(selfManaged)).toEqual(true);
      expect(hasDisabledInput(selfManaged)).toEqual(true);
    });

    it('displays the self-managed label and input when the Gitlab-managed checkbox is unchecked', () => {
      glManagedCheckbox.checked = false;
      glManagedCheckbox.dispatchEvent(changeEvent);

      expect(isHidden(glManaged)).toEqual(true);
      expect(hasDisabledInput(glManaged)).toEqual(true);

      expect(isHidden(selfManaged)).toEqual(false);
      expect(hasDisabledInput(selfManaged)).toEqual(false);
    });

    it('displays the GitLab-managed label and input when the Gitlab-managed checkbox is checked', () => {
      glManagedCheckbox.checked = true;
      glManagedCheckbox.dispatchEvent(changeEvent);

      expect(isHidden(glManaged)).toEqual(false);
      expect(hasDisabledInput(glManaged)).toEqual(false);

      expect(isHidden(selfManaged)).toEqual(true);
      expect(hasDisabledInput(selfManaged)).toEqual(true);
    });
  });
});