summaryrefslogtreecommitdiff
path: root/spec/javascripts/pages/admin/application_settings/account_and_limits_spec.js
blob: e3dcd55759ac36f256fdd307de141c165e68d883 (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 $ from 'jquery';
import initUserInternalRegexPlaceholder, { PLACEHOLDER_USER_EXTERNAL_DEFAULT_FALSE,
  PLACEHOLDER_USER_EXTERNAL_DEFAULT_TRUE } from '~/pages/admin/application_settings/account_and_limits';

describe('AccountAndLimits', () => {
  const FIXTURE = 'application_settings/accounts_and_limit.html.raw';
  let $userDefaultExternal;
  let $userInternalRegex;
  preloadFixtures(FIXTURE);

  beforeEach(() => {
    loadFixtures(FIXTURE);
    initUserInternalRegexPlaceholder();
    $userDefaultExternal = $('#application_setting_user_default_external');
    $userInternalRegex = document.querySelector('#application_setting_user_default_internal_regex');
  });

  describe('Changing of userInternalRegex when userDefaultExternal', () => {
    it('is unchecked', () => {
      expect($userDefaultExternal.prop('checked')).toBeFalsy();
      expect($userInternalRegex.placeholder).toEqual(PLACEHOLDER_USER_EXTERNAL_DEFAULT_FALSE);
      expect($userInternalRegex.readOnly).toBeTruthy();
    });

    it('is checked', (done) => {
      if (!$userDefaultExternal.prop('checked')) $userDefaultExternal.click();

      expect($userDefaultExternal.prop('checked')).toBeTruthy();
      expect($userInternalRegex.placeholder).toEqual(PLACEHOLDER_USER_EXTERNAL_DEFAULT_TRUE);
      expect($userInternalRegex.readOnly).toBeFalsy();
      done();
    });
  });
});