|
| 1 | +var assert = require('assert'); |
| 2 | +var sinon = require('sinon'); |
| 3 | +var Faker = require('../index'); |
| 4 | + |
| 5 | + |
| 6 | +// Basic smoke tests to make sure each method is at least implemented and returns a string. |
| 7 | + |
| 8 | +var modules = { |
| 9 | + Address: [ |
| 10 | + 'city', 'streetName', 'streetAddress', 'secondaryAddress', |
| 11 | + 'brState', 'ukCountry', 'ukCounty', 'usState', 'zipCode'//, 'zipCodeFormat' |
| 12 | + ], |
| 13 | + |
| 14 | + Company: ['companyName', 'companySuffix', 'catchPhrase', 'bs'], |
| 15 | + |
| 16 | + Internet: ['email', 'userName', 'domainName', 'domainWord', 'ip'], |
| 17 | + |
| 18 | + Lorem: ['words', 'sentence', 'sentences', 'paragraph', 'paragraphs'], |
| 19 | + |
| 20 | + Name: ['firstName', 'lastName', 'findName'], |
| 21 | + |
| 22 | + PhoneNumber: ['phoneNumber'] |
| 23 | +}; |
| 24 | + |
| 25 | +describe("functional tests", function () { |
| 26 | + Object.keys(modules).forEach(function (module) { |
| 27 | + describe(module, function () { |
| 28 | + modules[module].forEach(function (meth) { |
| 29 | + it(meth + "()", function () { |
| 30 | + var result = Faker[module][meth](); |
| 31 | + assert.ok(result); |
| 32 | + }); |
| 33 | + }); |
| 34 | + }); |
| 35 | + }); |
| 36 | + |
| 37 | + describe("Address", function() { |
| 38 | + it("zipCodeFormat()", function() { |
| 39 | + var result = Faker.Address.zipCodeFormat(0); |
| 40 | + assert.ok(!result.match(/-/)); |
| 41 | + |
| 42 | + result = Faker.Address.zipCodeFormat(1); |
| 43 | + assert.ok(result.match(/-/)); |
| 44 | + }); |
| 45 | + }); |
| 46 | +}); |
0 commit comments