2018-11-20 20:47:30 +05:30
|
|
|
import $ from 'jquery';
|
|
|
|
import UserInternalRegexHandler from '~/pages/admin/users/new/index';
|
|
|
|
|
|
|
|
describe('UserInternalRegexHandler', () => {
|
|
|
|
const FIXTURE = 'admin/users/new_with_internal_user_regex.html.raw';
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|