<commit_before>'use strict';
/**
 * @name validator.Spec
 * @author <NAME> <<EMAIL>>
 */
define(['src/Validator', 'src/validators/index', 'src/util'], function (Validator, validators, util) {
	describe('Validator Constructor', function () {
		var data = [
			{name: '<NAME>'}
		];
		var constrains = [];

		it('should return error if not pass data', function () {
			expect(function () {
				new Validator()
			}).toThrow(new Error('Parametro data não pode ser vazio.'));
		});

		it('should return error if not pass constrains', function () {
			expect(function () {
				new Validator(data)
			}).toThrow(new Error('Parametro constrains não pode ser vazio.'));
		});

		it('should return data', function () {
			var v = new Validator(data, constrains);

			expect(v.getData()).toEqual(data);
		});

		it('should return constrains', function () {
			var v = new Validator(data, constrains);

			expect(v.getConstrains()).toEqual(constrains);
		});
	});

	describe('Validator', function () {
		var data = [
			{name: '<NAME>'}
		];
		var constrains = [];

		var validator = new Validator(data, constrains);

		it('should return validateResult', function () {
			var result = validator.validate();

			expect(result.hasErrors()).toBeDefined();
			expect(result.getErrors()).toBeDefined();
			expect(result.getError()).toBeDefined();
		});

		it('should return new instance of validateResult on validate()', function () {
			var resultA = validator.validate();
			var resultB = validator.validate();

			expect(resultA).not.toBe(resultB);
		});

	});

	describe('expression', function () {

		describe('validators', function () {
			var data = {};
			var constrains = ['notEmpty($name)', 'email($name)'];

			var resultWithoutErrors = new Validator({}, []).validate();
			var resultWithErrors = new Validator(data, constrains).validate();

			it('should return boolean when execute hasErrors of resultValidate', function () {
				expect(resultWithoutErrors.hasErrors()).toBe(false);
				expect(resultWithErrors.hasErrors()).toBe(true);
			});

			it('should return errors', function () {
				expect(resultWithErrors.getErrors()).toEqual({name: {notEmpty: 'name deve ser preenchido.'}});
			});

			it('should return error message of path', function () {


				expect(resultWithErrors.getError('name')).toEqual({notEmpty: 'name deve ser preenchido.'});
				expect(resultWithErrors.getError('name.notEmpty')).toBe('name deve ser preenchido.');<commit_msg>created tests with validate functional<commit_after>'use strict';
/**
 * @name validator.Spec
 * @author <NAME> <<EMAIL>>
 */
define(['src/Validator', 'src/validators/index', 'src/util'], function (Validator, validators, util) {
	describe('Validator Constructor', function () {
		var data = [
			{name: '<NAME>'}
		];
		var constrains = [];

		it('should return error if not pass data', function () {
			expect(function () {
				new Validator()
			}).toThrow(new Error('Parametro data não pode ser vazio.'));
		});

		it('should return error if not pass constrains', function () {
			expect(function () {
				new Validator(data)
			}).toThrow(new Error('Parametro constrains não pode ser vazio.'));
		});

		it('should return data', function () {
			var v = new Validator(data, constrains);

			expect(v.getData()).toEqual(data);
		});

		it('should return constrains', function () {
			var v = new Validator(data, constrains);

			expect(v.getConstrains()).toEqual(constrains);
		});
	});

	describe('Validator', function () {
		var data = [
			{name: '<NAME>'}
		];
		var constrains = [];

		var validator = new Validator(data, constrains);

		it('should return validateResult', function () {
			var result = validator.validate();

			expect(result.hasErrors()).toBeDefined();
			expect(result.getErrors()).toBeDefined();
			expect(result.getError()).toBeDefined();
		});

		it('should return new instance of validateResult on validate()', function () {
			var resultA = validator.validate();
			var resultB = validator.validate();

			expect(resultA).not.toBe(resultB);
		});

	});

	describe('expression', function () {

		describe('validators', function () {
			var data = {};
			var constrains = ['notEmpty($name)'];

			var resultWithoutErrors = new Validator({}, []).validate();
			var resultWithErrors = new Validator(data, constrains).validate();

			it('should return boolean when execute hasErrors of resultValidate', function () {
				expect(resultWithoutErrors.hasErrors()).toBe(false);
				expect(resultWithErrors.hasErrors()).toBe(true);
			});

			it('should return errors', function () {
				expect(resultWithErrors.getErrors()).toEqual({name: {notEmpty: 'name deve ser preenchido.'}});
			});

			it('should return error message of path', function () {


				expect(resultWithErrors.getError('name')).toEqual({notEmpty: 'name deve ser preenchido.'});
				expect(resultWithErrors.getError('name.notEmpty')).toBe('name deve ser preenchido.');
{'fraction_non_alphanumeric': 0.16948462008555715, 'fraction_numerical': 0.0, 'mean_word_length': 4.348583877995643, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6502767', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1431, 'n_words': 352}