forked from zuriby/Faker.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphone_number.unit.js
31 lines (25 loc) · 1023 Bytes
/
phone_number.unit.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
if (typeof module !== 'undefined') {
var assert = require('assert');
var sinon = require('sinon');
var faker = require('../index');
}
describe("phone_number.js", function () {
describe("phoneNumber()", function () {
it("returns a random phoneNumber with a random format", function () {
sinon.spy(faker.helpers, 'replaceSymbolWithNumber');
var phone_number = faker.phone.phoneNumber();
assert.ok(phone_number.match(/\d/));
assert.ok(faker.helpers.replaceSymbolWithNumber.called);
faker.helpers.replaceSymbolWithNumber.restore();
});
});
describe("phoneNumberFormat()", function () {
faker.locale = "en";
it("returns phone number with requested format (Array index)", function () {
for (var i = 0; i < 10; i++) {
var phone_number = faker.phone.phoneNumberFormat(1);
assert.ok(phone_number.match(/\(\d\d\d\) \d\d\d-\d\d\d\d/));
}
});
});
});