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

token_access_app_spec.js « token_access « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7f269ee5fda4e3977b8709a43589cd6b0643e556 (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
import { shallowMount } from '@vue/test-utils';
import OutboundTokenAccess from '~/token_access/components/outbound_token_access.vue';
import InboundTokenAccess from '~/token_access/components/inbound_token_access.vue';
import OptInJwt from '~/token_access/components/opt_in_jwt.vue';
import TokenAccessApp from '~/token_access/components/token_access_app.vue';

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

  const findOutboundTokenAccess = () => wrapper.findComponent(OutboundTokenAccess);
  const findInboundTokenAccess = () => wrapper.findComponent(InboundTokenAccess);
  const findOptInJwt = () => wrapper.findComponent(OptInJwt);

  const createComponent = (flagState = false) => {
    wrapper = shallowMount(TokenAccessApp, {
      provide: {
        glFeatures: { ciInboundJobTokenScope: flagState },
      },
    });
  };

  describe('default', () => {
    beforeEach(() => {
      createComponent();
    });

    it('renders the opt in jwt component', () => {
      expect(findOptInJwt().exists()).toBe(true);
    });

    it('renders the outbound token access component', () => {
      expect(findOutboundTokenAccess().exists()).toBe(true);
    });

    it('does not render the inbound token access component', () => {
      expect(findInboundTokenAccess().exists()).toBe(false);
    });
  });

  describe('with feature flag enabled', () => {
    it('renders the inbound token access component', () => {
      createComponent(true);

      expect(findInboundTokenAccess().exists()).toBe(true);
    });
  });
});