faker 1.0.0 → 6.6.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of faker might be problematic. Click here for more details.

Files changed (60) hide show
  1. package/.eslintrc +54 -0
  2. package/.gitattributes +1 -0
  3. package/.github/FUNDING.yml +12 -0
  4. package/.travis.yml +7 -3
  5. package/.versions +23 -0
  6. package/Readme.md +1 -46
  7. package/package.json +70 -23
  8. package/.jshintrc +0 -87
  9. package/.npmignore +0 -16
  10. package/BUILD/BUILD.js +0 -139
  11. package/BUILD/Mustache.js +0 -296
  12. package/BUILD/docs.js +0 -62
  13. package/BUILD/main.js +0 -60
  14. package/MIT-LICENSE.txt +0 -20
  15. package/Makefile +0 -26
  16. package/examples/bigDataSet.json +0 -1
  17. package/examples/browser_test.html +0 -40
  18. package/examples/dataSet.json +0 -1
  19. package/examples/index.html +0 -77
  20. package/examples/js/faker.js +0 -730
  21. package/examples/js/jquery.js +0 -154
  22. package/examples/js/prettyPrint.js +0 -712
  23. package/examples/library_test.js +0 -9
  24. package/examples/node_generateSet.js +0 -20
  25. package/examples/node_min_test.js +0 -9
  26. package/faker.js +0 -730
  27. package/index.js +0 -31
  28. package/lib/address.js +0 -100
  29. package/lib/company.js +0 -36
  30. package/lib/date.js +0 -42
  31. package/lib/definitions.js +0 -1398
  32. package/lib/helpers.js +0 -124
  33. package/lib/image.js +0 -58
  34. package/lib/internet.js +0 -53
  35. package/lib/lorem.js +0 -45
  36. package/lib/name.js +0 -34
  37. package/lib/phone_number.js +0 -16
  38. package/lib/random.js +0 -106
  39. package/lib/tree.js +0 -69
  40. package/lib/version.js +0 -0
  41. package/logo.png +0 -0
  42. package/minfaker.js +0 -35
  43. package/test/address.unit.js +0 -293
  44. package/test/all.functional.js +0 -47
  45. package/test/browser.unit.html +0 -28
  46. package/test/company.unit.js +0 -110
  47. package/test/date.unit.js +0 -65
  48. package/test/helpers.unit.js +0 -62
  49. package/test/image.unit.js +0 -108
  50. package/test/internet.unit.js +0 -92
  51. package/test/lorem.unit.js +0 -178
  52. package/test/mocha.opts +0 -5
  53. package/test/name.unit.js +0 -87
  54. package/test/phone_number.unit.js +0 -29
  55. package/test/run.js +0 -68
  56. package/test/support/chai.js +0 -3403
  57. package/test/support/sinon-1.5.2.js +0 -4153
  58. package/test/support/walk_dir.js +0 -43
  59. package/test/tree.unit.js +0 -108
  60. /package/{.jshintignore → .eslintignore} +0 -0
@@ -1,108 +0,0 @@
1
- if (typeof module !== 'undefined') {
2
- var assert = require('assert');
3
- var sinon = require('sinon');
4
- var faker = require('../index');
5
- }
6
-
7
- describe("image.js", function () {
8
- describe("imageUrl()", function () {
9
- it("returns a random image url from lorempixel", function () {
10
- var imageUrl = faker.Image.imageUrl();
11
-
12
- assert.equal(imageUrl, 'http://lorempixel.com/640/480');
13
- });
14
- it("returns a random image url from lorempixel with width and height", function () {
15
- var imageUrl = faker.Image.imageUrl(100, 100);
16
-
17
- assert.equal(imageUrl, 'http://lorempixel.com/100/100');
18
- });
19
- it("returns a random image url for a specified category", function () {
20
- var imageUrl = faker.Image.imageUrl(100, 100, 'abstract');
21
-
22
- assert.equal(imageUrl, 'http://lorempixel.com/100/100/abstract');
23
- });
24
- });
25
- describe("avatar()", function () {
26
- it("return a random avatar from UIFaces", function () {
27
- assert.notEqual(-1, faker.Image.avatar().indexOf('s3.amazonaws.com/uifaces/faces'));
28
- })
29
- });
30
- describe("abstractImage()", function () {
31
- it("returns a random abstract image url", function () {
32
- var abstract = faker.Image.abstractImage();
33
- assert.equal(abstract, 'http://lorempixel.com/640/480/abstract');
34
- });
35
- });
36
- describe("animals()", function () {
37
- it("returns a random animals image url", function () {
38
- var animals = faker.Image.animals();
39
- assert.equal(animals, 'http://lorempixel.com/640/480/animals');
40
- });
41
- });
42
- describe("business()", function () {
43
- it("returns a random business image url", function () {
44
- var business = faker.Image.business();
45
- assert.equal(business, 'http://lorempixel.com/640/480/business');
46
- });
47
- });
48
- describe("cats()", function () {
49
- it("returns a random cats image url", function () {
50
- var cats = faker.Image.cats();
51
- assert.equal(cats, 'http://lorempixel.com/640/480/cats');
52
- });
53
- });
54
- describe("city()", function () {
55
- it("returns a random city image url", function () {
56
- var city = faker.Image.city();
57
- assert.equal(city, 'http://lorempixel.com/640/480/city');
58
- });
59
- });
60
- describe("food()", function () {
61
- it("returns a random food image url", function () {
62
- var food = faker.Image.food();
63
- assert.equal(food, 'http://lorempixel.com/640/480/food');
64
- });
65
- });
66
- describe("nightlife()", function () {
67
- it("returns a random nightlife image url", function () {
68
- var nightlife = faker.Image.nightlife();
69
- assert.equal(nightlife, 'http://lorempixel.com/640/480/nightlife');
70
- });
71
- });
72
- describe("fashion()", function () {
73
- it("returns a random fashion image url", function () {
74
- var fashion = faker.Image.fashion();
75
- assert.equal(fashion, 'http://lorempixel.com/640/480/fashion');
76
- });
77
- });
78
- describe("people()", function () {
79
- it("returns a random people image url", function () {
80
- var people = faker.Image.people();
81
- assert.equal(people, 'http://lorempixel.com/640/480/people');
82
- });
83
- });
84
- describe("nature()", function () {
85
- it("returns a random nature image url", function () {
86
- var nature = faker.Image.nature();
87
- assert.equal(nature, 'http://lorempixel.com/640/480/nature');
88
- });
89
- });
90
- describe("sports()", function () {
91
- it("returns a random sports image url", function () {
92
- var sports = faker.Image.sports();
93
- assert.equal(sports, 'http://lorempixel.com/640/480/sports');
94
- });
95
- });
96
- describe("technics()", function () {
97
- it("returns a random technics image url", function () {
98
- var technics = faker.Image.technics();
99
- assert.equal(technics, 'http://lorempixel.com/640/480/technics');
100
- });
101
- });
102
- describe("transport()", function () {
103
- it("returns a random transport image url", function () {
104
- var transport = faker.Image.transport();
105
- assert.equal(transport, 'http://lorempixel.com/640/480/transport');
106
- });
107
- });
108
- });
@@ -1,92 +0,0 @@
1
- if (typeof module !== 'undefined') {
2
- var assert = require('assert');
3
- var sinon = require('sinon');
4
- var faker = require('../index');
5
- }
6
-
7
- describe("internet.js", function () {
8
- describe("email()", function () {
9
- it("returns a userName@domainName", function () {
10
- sinon.stub(faker.Internet, 'userName').returns('Aiden.Harªann');
11
- sinon.stub(faker.Internet, 'domainName').returns("ex'ample.net");
12
- var email = faker.Internet.email();
13
-
14
- assert.equal(email, 'Aiden.Harann@example.net');
15
-
16
- faker.Internet.userName.restore();
17
- faker.Internet.domainName.restore();
18
- });
19
- });
20
-
21
- describe("userName()", function () {
22
- it("occasionally returns a single firstName", function () {
23
- sinon.stub(faker.random, 'number').returns(0);
24
- sinon.spy(faker.random, 'first_name');
25
- var username = faker.Internet.userName();
26
-
27
- assert.ok(username);
28
- assert.ok(faker.random.first_name.called);
29
-
30
- faker.random.number.restore();
31
- faker.random.first_name.restore();
32
- });
33
-
34
- it("occasionally returns a firstName with a period or hyphen and a lastName", function () {
35
- sinon.stub(faker.random, 'number').returns(1);
36
- sinon.spy(faker.random, 'first_name');
37
- sinon.spy(faker.random, 'last_name');
38
- sinon.spy(faker.random, 'array_element');
39
- var username = faker.Internet.userName();
40
-
41
- assert.ok(username);
42
- assert.ok(faker.random.first_name.called);
43
- assert.ok(faker.random.last_name.called);
44
- assert.ok(faker.random.array_element.calledWith(['.', '_']));
45
-
46
- faker.random.number.restore();
47
- faker.random.first_name.restore();
48
- faker.random.last_name.restore();
49
- });
50
- });
51
-
52
- describe("domainName()", function () {
53
- it("returns a domainWord plus a random suffix", function () {
54
- sinon.stub(faker.Internet, 'domainWord').returns('bar');
55
- sinon.stub(faker.random, 'domain_suffix').returns('net');
56
-
57
- var domain_name = faker.Internet.domainName();
58
-
59
- assert.equal(domain_name, 'bar.net');
60
-
61
- faker.Internet.domainWord.restore();
62
- faker.random.domain_suffix.restore();
63
- });
64
- });
65
-
66
- describe("domainWord()", function () {
67
- it("returns a lower-case firstName", function () {
68
- sinon.stub(faker.random, 'first_name').returns('FOO');
69
- var domain_word = faker.Internet.domainWord();
70
-
71
- assert.ok(domain_word);
72
- assert.strictEqual(domain_word, 'foo');
73
-
74
- faker.random.first_name.restore();
75
- });
76
- });
77
-
78
- describe("ip()", function () {
79
- it("returns a random IP address with four parts", function () {
80
- var ip = faker.Internet.ip();
81
- var parts = ip.split('.');
82
- assert.equal(parts.length, 4);
83
- });
84
- });
85
-
86
- describe("color()", function () {
87
- it("returns a valid hex value (like #ffffff)", function () {
88
- var color = faker.Internet.color(100, 100, 100);
89
- assert.ok(color.match(/^#[a-f0-9]{6}$/));
90
- });
91
- });
92
- });
@@ -1,178 +0,0 @@
1
- if (typeof module !== 'undefined') {
2
- var assert = require('assert');
3
- var sinon = require('sinon');
4
- var faker = require('../index');
5
- }
6
-
7
- describe("lorem.js", function () {
8
- describe("words()", function () {
9
- beforeEach(function () {
10
- sinon.spy(faker.Helpers, 'shuffle');
11
- });
12
-
13
- afterEach(function () {
14
- faker.Helpers.shuffle.restore();
15
- });
16
-
17
- context("when no 'num' param passed in", function () {
18
- it("returns three words", function () {
19
- var words = faker.Lorem.words();
20
-
21
- assert.ok(Array.isArray(words));
22
- assert.equal(words.length, 3);
23
- assert.ok(faker.Helpers.shuffle.called);
24
- });
25
- });
26
-
27
- context("when 'num' param passed in", function () {
28
- it("returns requested number of words", function () {
29
- var words = faker.Lorem.words(7);
30
-
31
- assert.ok(Array.isArray(words));
32
- assert.equal(words.length, 7);
33
- });
34
- });
35
- });
36
-
37
- describe("sentence()", function () {
38
- context("when no 'wordCount' or 'range' param passed in", function () {
39
- it("returns a string of at least three words", function () {
40
- sinon.spy(faker.Lorem, 'words');
41
- sinon.stub(faker.random, 'number').returns(2);
42
- var sentence = faker.Lorem.sentence();
43
-
44
- assert.ok(typeof sentence === 'string');
45
- var parts = sentence.split(' ');
46
- assert.equal(parts.length, 5); // default 3 plus stubbed 2.
47
- assert.ok(faker.Lorem.words.calledWith(5));
48
-
49
- faker.Lorem.words.restore();
50
- faker.random.number.restore();
51
- });
52
- });
53
-
54
- context("when 'wordCount' param passed in", function () {
55
- it("returns a string of at least the requested number of words", function () {
56
- sinon.spy(faker.Lorem, 'words');
57
- sinon.stub(faker.random, 'number').returns(2);
58
- var sentence = faker.Lorem.sentence(10);
59
-
60
- assert.ok(typeof sentence === 'string');
61
- var parts = sentence.split(' ');
62
- assert.equal(parts.length, 12); // requested 10 plus stubbed 2.
63
- assert.ok(faker.Lorem.words.calledWith(12));
64
-
65
- faker.Lorem.words.restore();
66
- faker.random.number.restore();
67
- });
68
- });
69
-
70
- context("when 'wordCount' and 'range' params passed in", function () {
71
- it("returns a string of at least the requested number of words", function () {
72
- sinon.spy(faker.Lorem, 'words');
73
- sinon.stub(faker.random, 'number').returns(4);
74
- var sentence = faker.Lorem.sentence(10, 4);
75
-
76
- assert.ok(typeof sentence === 'string');
77
- var parts = sentence.split(' ');
78
- assert.equal(parts.length, 14); // requested 10 plus stubbed 4.
79
- assert.ok(faker.Lorem.words.calledWith(14));
80
-
81
- faker.Lorem.words.restore();
82
- faker.random.number.restore();
83
- });
84
- });
85
- });
86
-
87
- describe("sentences()", function () {
88
- context("when no 'sentenceCount' param passed in", function () {
89
- it("returns newline-separated string of three sentences", function () {
90
- sinon.spy(faker.Lorem, 'sentence');
91
- var sentences = faker.Lorem.sentences();
92
-
93
- assert.ok(typeof sentences === 'string');
94
- var parts = sentences.split('\n');
95
- assert.equal(parts.length, 3);
96
- assert.ok(faker.Lorem.sentence.calledThrice);
97
-
98
- faker.Lorem.sentence.restore();
99
- });
100
- });
101
-
102
- context("when 'sentenceCount' param passed in", function () {
103
- it("returns newline-separated string of requested number of sentences", function () {
104
- sinon.spy(faker.Lorem, 'sentence');
105
- var sentences = faker.Lorem.sentences(5);
106
-
107
- assert.ok(typeof sentences === 'string');
108
- var parts = sentences.split('\n');
109
- assert.equal(parts.length, 5);
110
-
111
- faker.Lorem.sentence.restore();
112
- });
113
- });
114
- });
115
-
116
- describe("paragraph()", function () {
117
- context("when no 'wordCount' param passed in", function () {
118
- it("returns a string of at least three sentences", function () {
119
- sinon.spy(faker.Lorem, 'sentences');
120
- sinon.stub(faker.random, 'number').returns(2);
121
- var paragraph = faker.Lorem.paragraph();
122
-
123
- assert.ok(typeof paragraph === 'string');
124
- var parts = paragraph.split('\n');
125
- assert.equal(parts.length, 5); // default 3 plus stubbed 2.
126
- assert.ok(faker.Lorem.sentences.calledWith(5));
127
-
128
- faker.Lorem.sentences.restore();
129
- faker.random.number.restore();
130
- });
131
- });
132
-
133
- context("when 'wordCount' param passed in", function () {
134
- it("returns a string of at least the requested number of sentences", function () {
135
- sinon.spy(faker.Lorem, 'sentences');
136
- sinon.stub(faker.random, 'number').returns(2);
137
- var paragraph = faker.Lorem.paragraph(10);
138
-
139
- assert.ok(typeof paragraph === 'string');
140
- var parts = paragraph.split('\n');
141
- assert.equal(parts.length, 12); // requested 10 plus stubbed 2.
142
- assert.ok(faker.Lorem.sentences.calledWith(12));
143
-
144
- faker.Lorem.sentences.restore();
145
- faker.random.number.restore();
146
- });
147
- });
148
- });
149
-
150
- describe("paragraphs()", function () {
151
- context("when no 'paragraphCount' param passed in", function () {
152
- it("returns newline-separated string of three paragraphs", function () {
153
- sinon.spy(faker.Lorem, 'paragraph');
154
- var paragraphs = faker.Lorem.paragraphs();
155
-
156
- assert.ok(typeof paragraphs === 'string');
157
- var parts = paragraphs.split('\n \r\t');
158
- assert.equal(parts.length, 3);
159
- assert.ok(faker.Lorem.paragraph.calledThrice);
160
-
161
- faker.Lorem.paragraph.restore();
162
- });
163
- });
164
-
165
- context("when 'paragraphCount' param passed in", function () {
166
- it("returns newline-separated string of requested number of paragraphs", function () {
167
- sinon.spy(faker.Lorem, 'paragraph');
168
- var paragraphs = faker.Lorem.paragraphs(5);
169
-
170
- assert.ok(typeof paragraphs === 'string');
171
- var parts = paragraphs.split('\n \r\t');
172
- assert.equal(parts.length, 5);
173
-
174
- faker.Lorem.paragraph.restore();
175
- });
176
- });
177
- });
178
- });
package/test/mocha.opts DELETED
@@ -1,5 +0,0 @@
1
- --reporter spec
2
- --ui bdd
3
- --globals state,newBlocks,params,type,__coverage__
4
- --timeout 6500
5
- --slow 200
package/test/name.unit.js DELETED
@@ -1,87 +0,0 @@
1
- if (typeof module !== 'undefined') {
2
- var assert = require('assert');
3
- var sinon = require('sinon');
4
- var faker = require('../index');
5
-
6
- }
7
-
8
- describe("name.js", function () {
9
- describe("firstName()", function () {
10
- it("returns a random name", function () {
11
- sinon.stub(faker.random, 'first_name').returns('foo');
12
- var first_name = faker.Name.firstName();
13
-
14
- assert.equal(first_name, 'foo');
15
-
16
- faker.random.first_name.restore();
17
- });
18
- });
19
-
20
- describe("firstNameFemale()", function () {
21
- it("returns a random name", function () {
22
- sinon.stub(faker.random, 'first_name').returns('foo');
23
- var first_name = faker.Name.firstNameFemale();
24
-
25
- assert.equal(first_name, 'foo');
26
-
27
- faker.random.first_name.restore();
28
- });
29
- });
30
-
31
- describe("firstNameMale()", function () {
32
- it("returns a random name", function () {
33
- sinon.stub(faker.random, 'first_name').returns('foo');
34
- var first_name = faker.Name.firstNameMale();
35
-
36
- assert.equal(first_name, 'foo');
37
-
38
- faker.random.first_name.restore();
39
- });
40
- });
41
-
42
-
43
- describe("lastName()", function () {
44
- it("returns a random name", function () {
45
- sinon.stub(faker.random, 'last_name').returns('foo');
46
-
47
- var last_name = faker.Name.lastName();
48
-
49
- assert.equal(last_name, 'foo');
50
-
51
- faker.random.last_name.restore();
52
- });
53
- });
54
-
55
- describe("findName()", function () {
56
- it("usually returns a first name and last name", function () {
57
- sinon.stub(faker.random, 'number').returns(5);
58
- var name = faker.Name.findName();
59
- assert.ok(name);
60
- var parts = name.split(' ');
61
-
62
- assert.strictEqual(parts.length, 2);
63
-
64
- faker.random.number.restore();
65
- });
66
-
67
- it("occasionally returns a first name and last name with a prefix", function () {
68
- sinon.stub(faker.random, 'number').returns(0);
69
- var name = faker.Name.findName();
70
- var parts = name.split(' ');
71
-
72
- assert.ok(parts.length >= 3);
73
-
74
- faker.random.number.restore();
75
- });
76
-
77
- it("occasionally returns a first name and last name with a suffix", function () {
78
- sinon.stub(faker.random, 'number').returns(1);
79
- var name = faker.Name.findName();
80
- var parts = name.split(' ');
81
-
82
- assert.ok(parts.length >= 3);
83
-
84
- faker.random.number.restore();
85
- });
86
- });
87
- });
@@ -1,29 +0,0 @@
1
- if (typeof module !== 'undefined') {
2
- var assert = require('assert');
3
- var sinon = require('sinon');
4
- var faker = require('../index');
5
- }
6
-
7
- describe("phone_number.js", function () {
8
- describe("phoneNumber()", function () {
9
- it("returns a random phoneNumber with a random format", function () {
10
- sinon.spy(faker.random, 'phone_formats');
11
- sinon.spy(faker.Helpers, 'replaceSymbolWithNumber');
12
- var phone_number = faker.PhoneNumber.phoneNumber();
13
-
14
- assert.ok(phone_number.match(/\d/));
15
- assert.ok(faker.random.phone_formats.called);
16
- assert.ok(faker.Helpers.replaceSymbolWithNumber.called);
17
-
18
- faker.random.phone_formats.restore();
19
- faker.Helpers.replaceSymbolWithNumber.restore();
20
- });
21
- });
22
-
23
- describe("phoneNumberFormat()", function () {
24
- it("returns phone number with requested format (Array index)", function () {
25
- var phone_number = faker.PhoneNumber.phoneNumberFormat(5);
26
- assert.ok(phone_number.match(/\(\d\d\d\)\d\d\d-\d\d\d\d/));
27
- });
28
- });
29
- });
package/test/run.js DELETED
@@ -1,68 +0,0 @@
1
- #!/usr/bin/env node
2
- process.env.NODE_ENV = 'test';
3
-
4
- var fs = require('fs');
5
- var Mocha = require('mocha');
6
- var optimist = require('optimist');
7
- var walk_dir = require('./support/walk_dir');
8
-
9
- var argv = optimist
10
- .usage("Usage: $0 -t [types] --reporter [reporter] --timeout [timeout]")
11
- .default({types: 'unit,functional', reporter: 'spec', timeout: 6000})
12
- .describe('types', 'The types of tests to run, separated by commas. E.g., unit,functional,acceptance')
13
- .describe('reporter', 'The mocha test reporter to use.')
14
- .describe('timeout', 'The mocha timeout to use per test (ms).')
15
- .boolean('help')
16
- .alias('types', 'T')
17
- .alias('timeout', 't')
18
- .alias('reporter', 'R')
19
- .alias('help', 'h')
20
- .argv;
21
-
22
- var mocha = new Mocha({timeout: argv.timeout, reporter: argv.reporter, ui: 'bdd'});
23
-
24
- var valid_test_types = ['unit', 'functional', 'acceptance', 'integration'];
25
- var requested_types = argv.types.split(',');
26
- var types_to_use = [];
27
-
28
- valid_test_types.forEach(function (valid_test_type) {
29
- if (requested_types.indexOf(valid_test_type) !== -1) {
30
- types_to_use.push(valid_test_type);
31
- }
32
- });
33
-
34
- if (argv.help || types_to_use.length === 0) {
35
- console.log('\n' + optimist.help());
36
- process.exit();
37
- }
38
-
39
- var is_valid_file = function (file) {
40
- for (var i = 0; i < types_to_use.length; i++) {
41
- var test_type = types_to_use[i];
42
- var ext = test_type + ".js";
43
-
44
- if (file.indexOf(ext) !== -1) {
45
- return true;
46
- }
47
- }
48
-
49
- return false;
50
- };
51
-
52
- function run(cb) {
53
- walk_dir.walk('test', is_valid_file, function (err, files) {
54
- if (err) { return cb(err); }
55
-
56
- files.forEach(function (file) {
57
- mocha.addFile(file);
58
- });
59
-
60
- cb();
61
- });
62
- }
63
-
64
- run(function (err) {
65
- mocha.run(function (failures) {
66
- process.exit(failures);
67
- });
68
- });