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

mutations_spec.js « store « import_projects « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 505545f7aa5d22aafa6d637485e1bc02191d04de (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
import * as types from '~/import_projects/store/mutation_types';
import mutations from '~/import_projects/store/mutations';

describe('import_projects store mutations', () => {
  describe(`${types.RECEIVE_IMPORT_SUCCESS}`, () => {
    it('removes repoId from reposBeingImported and providerRepos, adds to importedProjects', () => {
      const repoId = 1;
      const state = {
        reposBeingImported: [repoId],
        providerRepos: [{ id: repoId }],
        importedProjects: [],
      };
      const importedProject = { id: repoId };

      mutations[types.RECEIVE_IMPORT_SUCCESS](state, { importedProject, repoId });

      expect(state.reposBeingImported.includes(repoId)).toBe(false);
      expect(state.providerRepos.some(repo => repo.id === repoId)).toBe(false);
      expect(state.importedProjects.some(repo => repo.id === repoId)).toBe(true);
    });
  });

  describe(`${types.RECEIVE_JOBS_SUCCESS}`, () => {
    it('updates importStatus of existing importedProjects', () => {
      const repoId = 1;
      const state = { importedProjects: [{ id: repoId, importStatus: 'started' }] };
      const updatedProjects = [{ id: repoId, importStatus: 'finished' }];

      mutations[types.RECEIVE_JOBS_SUCCESS](state, updatedProjects);

      expect(state.importedProjects[0].importStatus).toBe(updatedProjects[0].importStatus);
    });
  });
});