node-validator/test/phone-validator.js

42 lines
1.0 KiB
JavaScript

"use strict";
var $V = require('../lib/md-validator');
var assert = require('assert');
describe('Phone Validator', function() {
it('should not validate an empty phone number', function(done) {
assert.equal($V.validatePhone({number: ''}), '');
done();
});
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();
});
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();
});
it('should validate a number with no options', function(done) {
assert.equal($V.validatePhone('01389 602001'),
'01389602001');
done();
});
});