2016-03-15 17:34:51 +00:00
|
|
|
"use strict";
|
2016-03-16 10:40:27 +00:00
|
|
|
var $V = require('../lib/md-validator');
|
2016-03-15 17:34:51 +00:00
|
|
|
|
|
|
|
var assert = require('assert');
|
|
|
|
|
|
|
|
describe('Phone Validator', function() {
|
|
|
|
it('should not validate an empty phone number', function(done) {
|
|
|
|
assert.equal($V.validatePhone({number: ''}), '');
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2016-03-18 11:44:15 +00:00
|
|
|
it('should not validate an non existing object', function(done) {
|
|
|
|
assert.equal($V.validatePhone(), '');
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not validate an null object', function(done) {
|
|
|
|
assert.equal($V.validatePhone(null), '');
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2016-03-15 17:34:51 +00:00
|
|
|
it('should validate an normal uk number', function(done) {
|
|
|
|
assert.equal($V.validatePhone({number: '01389 602001', uk: true}),
|
|
|
|
'01389602001');
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should validate an normal prefixed uk number', function(done) {
|
|
|
|
assert.equal($V.validatePhone({number: '+441389 602002', uk: true}),
|
|
|
|
'01389602002');
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2016-03-16 11:04:34 +00:00
|
|
|
it('should validate a number with no options', function(done) {
|
|
|
|
assert.equal($V.validatePhone('01389 602001'),
|
|
|
|
'01389602001');
|
2016-03-15 17:34:51 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|