debian-mirror-gitlab/spec/javascripts/pages/admin/users/new/index_spec.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-11-20 20:47:30 +05:30
import $ from 'jquery';
import UserInternalRegexHandler from '~/pages/admin/users/new/index';
describe('UserInternalRegexHandler', () => {
2019-07-07 11:18:12 +05:30
const FIXTURE = 'admin/users/new_with_internal_user_regex.html';
2018-11-20 20:47:30 +05:30
let $userExternal;
let $userEmail;
let $warningMessage;
preloadFixtures(FIXTURE);
beforeEach(() => {
loadFixtures(FIXTURE);
// eslint-disable-next-line no-new
new UserInternalRegexHandler();
$userExternal = $('#user_external');
$userEmail = $('#user_email');
$warningMessage = $('#warning_external_automatically_set');
if (!$userExternal.prop('checked')) $userExternal.prop('checked', 'checked');
});
describe('Behaviour of userExternal checkbox when', () => {
2018-12-13 13:39:08 +05:30
it('matches email as internal', done => {
2018-11-20 20:47:30 +05:30
expect($warningMessage.hasClass('hidden')).toBeTruthy();
$userEmail.val('test@').trigger('input');
expect($userExternal.prop('checked')).toBeFalsy();
expect($warningMessage.hasClass('hidden')).toBeFalsy();
done();
});
2018-12-13 13:39:08 +05:30
it('matches email as external', done => {
2018-11-20 20:47:30 +05:30
expect($warningMessage.hasClass('hidden')).toBeTruthy();
$userEmail.val('test.ext@').trigger('input');
expect($userExternal.prop('checked')).toBeTruthy();
expect($warningMessage.hasClass('hidden')).toBeTruthy();
done();
});
});
});