mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
error handling levels
This commit is contained in:
@@ -18,11 +18,15 @@
|
||||
import isBlankString from './isBlankString';
|
||||
import {mockAlert} from '../setUpTests';
|
||||
|
||||
|
||||
import setup from '../components/error/setUpTests';
|
||||
|
||||
'use strict';
|
||||
|
||||
mockAlert();
|
||||
|
||||
it('getFromUrl workds', () => {
|
||||
document.querySelector('body').appendChild(setup());
|
||||
expect(isBlankString('test', 'username')).toBe(false);
|
||||
try {
|
||||
isBlankString(' ', 'username');
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import createError from '../components/error/';
|
||||
|
||||
const isBlankString = (value: string|number, field: string, event?: Event) => {
|
||||
value = value.toString();
|
||||
@@ -22,7 +23,7 @@ const isBlankString = (value: string|number, field: string, event?: Event) => {
|
||||
event.preventDefault();
|
||||
}
|
||||
const msg = `${field} can't be empty`;
|
||||
alert(msg);
|
||||
createError(msg);
|
||||
throw new Error(msg);
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user