diff options
| -rw-r--r-- | lib/internet.js | 15 | ||||
| -rw-r--r-- | test/internet.unit.js | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/internet.js b/lib/internet.js index 658607a1..9d322d48 100644 --- a/lib/internet.js +++ b/lib/internet.js @@ -132,6 +132,21 @@ var Internet = function (faker) { }; /** + * method + * + * @method faker.internet.httpMethod + */ + self.httpMethod = function () { + var httpMethods = ['GET','POST', 'PUT', 'DELETE', 'PATCH']; + return faker.random.arrayElement(httpMethods); + }; + + self.httpMethod.schema = { + "description": "Randomly generates HTTP Methods (GET, POST, PUT, DELETE, PATCH)", + "sampleResults": ["GET","POST", "PUT", "DELETE", "PATCH"] + }; + + /** * url * * @method faker.internet.url diff --git a/test/internet.unit.js b/test/internet.unit.js index a554cea0..d16ccced 100644 --- a/test/internet.unit.js +++ b/test/internet.unit.js @@ -125,6 +125,14 @@ describe("internet.js", function () { }); }); + describe('httpMethod()', function () { + it('returns a valid http method', function () { + var httpMethods = ['GET','POST', 'PUT', 'DELETE', 'PATCH']; + var method = faker.internet.httpMethod(); + assert.ok(httpMethods.includes(method)); + }); + }); + describe('url()', function () { it('returns a valid url', function () { sinon.stub(faker.internet,'protocol').returns('http'); |
