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

alert_spec.js « getters « stores « ide « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7068b8e637f6ccdbab29f67f3cf0b0be0743baa8 (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
import { getAlert } from '~/ide/lib/alerts';
import EnvironmentsMessage from '~/ide/lib/alerts/environments.vue';
import { createStore } from '~/ide/stores';
import * as getters from '~/ide/stores/getters/alert';
import { file } from '../../helpers';

describe('IDE store alert getters', () => {
  let localState;
  let localStore;

  beforeEach(() => {
    localStore = createStore();
    localState = localStore.state;
  });

  describe('alerts', () => {
    describe('shows an alert about environments', () => {
      let alert;

      beforeEach(() => {
        const f = file('.gitlab-ci.yml');
        localState.openFiles.push(f);
        localState.currentActivityView = 'repo-commit-section';
        localState.environmentsGuidanceAlertDetected = true;
        localState.environmentsGuidanceAlertDismissed = false;

        const alertKey = getters.getAlert(localState)(f);
        alert = getAlert(alertKey);
      });

      it('has a message suggesting to use environments', () => {
        expect(alert.message).toEqual(EnvironmentsMessage);
      });

      it('dispatches to dismiss the callout on dismiss', () => {
        jest.spyOn(localStore, 'dispatch').mockImplementation();
        alert.dismiss(localStore);
        expect(localStore.dispatch).toHaveBeenCalledWith('dismissEnvironmentsGuidance');
      });

      it('should be a tip alert', () => {
        expect(alert.props).toEqual({ variant: 'tip' });
      });
    });
  });
});