summaryrefslogtreecommitdiff
path: root/spec/frontend/ci/runner/components/registration/utils_spec.js
blob: aeb489ca7de1dc9c78657f7dfb75dba7d36782d8 (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
import { TEST_HOST } from 'helpers/test_constants';
import {
  DEFAULT_PLATFORM,
  LINUX_PLATFORM,
  MACOS_PLATFORM,
  WINDOWS_PLATFORM,
} from '~/ci/runner/constants';

import {
  commandPrompt,
  registerCommand,
  runCommand,
} from '~/ci/runner/components/registration/utils';

const REGISTRATION_TOKEN = 'REGISTRATION_TOKEN';
const DUMMY_GON = {
  gitlab_url: TEST_HOST,
};

describe('registration utils', () => {
  let originalGon;

  beforeAll(() => {
    originalGon = window.gon;
    window.gon = { ...DUMMY_GON };
  });

  afterAll(() => {
    window.gon = originalGon;
  });

  describe.each([DEFAULT_PLATFORM, LINUX_PLATFORM, MACOS_PLATFORM, WINDOWS_PLATFORM, null])(
    'for "%s" platform',
    (platform) => {
      describe('commandPrompt', () => {
        it('matches snapshot', () => {
          expect(commandPrompt({ platform })).toMatchSnapshot();
        });
      });
      describe('registerCommand', () => {
        it('matches snapshot', () => {
          expect(
            registerCommand({ platform, registrationToken: REGISTRATION_TOKEN }),
          ).toMatchSnapshot();
        });
      });
      describe('runCommand', () => {
        it('matches snapshot', () => {
          expect(runCommand({ platform })).toMatchSnapshot();
        });
      });
    },
  );
});