-
Notifications
You must be signed in to change notification settings - Fork 10
/
not-equal-email-domain.spec.js
59 lines (46 loc) · 2.04 KB
/
not-equal-email-domain.spec.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { expect } from 'chai';
import validator from '../../lib';
describe('Not equal email domain validator', () => {
const rules = {
someField: ['not-equal-email-domain:cermati.com,indodana.com']
};
it('should success with empty email', () => {
const result = validator.validate(rules, {someField: ''});
const err = result.messages;
expect(result.success).to.equal(true);
expect(err).to.not.have.property('someField');
});
it('should success with domain gmail.com', () => {
const result = validator.validate(rules, {someField: 'randy@gmail.com'});
const err = result.messages;
expect(result.success).to.equal(true);
expect(err).to.not.have.property('someField');
});
it('should success with domain yahoo.com', () => {
const result = validator.validate(rules, {someField: 'randy@yahoo.com'});
const err = result.messages;
expect(result.success).to.equal(true);
expect(err).to.not.have.property('someField');
});
it('should fail with invalid email', () => {
const result = validator.validate(rules, {someField: 'randygmail.com'});
const err = result.messages;
expect(result.success).to.equal(false);
expect(err).to.have.property('someField');
expect(err.someField['not-equal-email-domain:$1']).to.equal('Some Field\'s domain is not valid.');
});
it('should fail with domain cermati.com', () => {
const result = validator.validate(rules, {someField: 'randy@cermati.com'});
const err = result.messages;
expect(result.success).to.equal(false);
expect(err).to.have.property('someField');
expect(err.someField['not-equal-email-domain:$1']).to.equal('Some Field\'s domain is not valid.');
});
it('should fail with domain indodana.com', () => {
const result = validator.validate(rules, {someField: 'randy@indodana.com'});
const err = result.messages;
expect(result.success).to.equal(false);
expect(err).to.have.property('someField');
expect(err.someField['not-equal-email-domain:$1']).to.equal('Some Field\'s domain is not valid.');
});
});