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

home_spec.js « components « google_cloud « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 57cf831b19baea06e2d37236e2571487551c9461 (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
62
63
import { shallowMount } from '@vue/test-utils';
import { GlTab, GlTabs } from '@gitlab/ui';
import Home from '~/google_cloud/components/home.vue';
import ServiceAccountsList from '~/google_cloud/components/service_accounts_list.vue';

describe('google_cloud Home component', () => {
  let wrapper;

  const findTabs = () => wrapper.findComponent(GlTabs);
  const findTabItems = () => findTabs().findAllComponents(GlTab);
  const findTabItemsModel = () =>
    findTabs()
      .findAllComponents(GlTab)
      .wrappers.map((x) => ({
        title: x.attributes('title'),
        disabled: x.attributes('disabled'),
      }));

  const TEST_HOME_PROPS = {
    serviceAccounts: [{}, {}],
    createServiceAccountUrl: '#url-create-service-account',
    emptyIllustrationUrl: '#url-empty-illustration',
    enableCloudRunUrl: '#url-enable-cloud-run',
    enableCloudStorageUrl: '#enableCloudStorageUrl',
  };

  beforeEach(() => {
    const propsData = {
      screen: 'home',
      ...TEST_HOME_PROPS,
    };
    wrapper = shallowMount(Home, { propsData });
  });

  afterEach(() => {
    wrapper.destroy();
  });

  describe('google_cloud App tabs', () => {
    it('should contain tabs', () => {
      expect(findTabs().exists()).toBe(true);
    });

    it('should contain three tab items', () => {
      expect(findTabItemsModel()).toEqual([
        { title: 'Configuration', disabled: undefined },
        { title: 'Deployments', disabled: undefined },
        { title: 'Services', disabled: '' },
      ]);
    });

    describe('configuration tab', () => {
      it('should contain service accounts component', () => {
        const serviceAccounts = findTabItems().at(0).findComponent(ServiceAccountsList);
        expect(serviceAccounts.props()).toEqual({
          list: TEST_HOME_PROPS.serviceAccounts,
          createUrl: TEST_HOME_PROPS.createServiceAccountUrl,
          emptyIllustrationUrl: TEST_HOME_PROPS.emptyIllustrationUrl,
        });
      });
    });
  });
});