summaryrefslogtreecommitdiff
path: root/spec/frontend/constants_spec.js
blob: b596b62f72c0c33d4f284ceb427edd8f2d63e98f (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
import * as constants from '~/constants';

describe('Global JS constants', () => {
  describe('getModifierKey()', () => {
    afterEach(() => {
      delete window.gl;
    });

    it.each`
      isMac    | removeSuffix | expectedKey
      ${true}  | ${false}     | ${'⌘'}
      ${false} | ${false}     | ${'Ctrl+'}
      ${true}  | ${true}      | ${'⌘'}
      ${false} | ${true}      | ${'Ctrl'}
    `(
      'returns correct keystroke when isMac=$isMac and removeSuffix=$removeSuffix',
      ({ isMac, removeSuffix, expectedKey }) => {
        Object.assign(window, {
          gl: {
            client: {
              isMac,
            },
          },
        });

        expect(constants.getModifierKey(removeSuffix)).toBe(expectedKey);
      },
    );
  });
});