aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarak <[email protected]>2021-02-08 23:36:22 -0500
committerGitHub <[email protected]>2021-02-08 23:36:22 -0500
commit8b0abfbf5ba2deb34a653ce6f41130256c08b9d6 (patch)
tree7751f8957414223fb3f8e7b27a334e946ea6b32f
parent251b0447e0644b748d01d32781d1c2b6c902fe88 (diff)
parentff669022d0a0de0d585a04676eeb2891de76d43e (diff)
downloadfaker-8b0abfbf5ba2deb34a653ce6f41130256c08b9d6.tar.xz
faker-8b0abfbf5ba2deb34a653ce6f41130256c08b9d6.zip
Merge pull request #1013 from ariel-enso/feature/add-internet-http-methods
Feature: add http methods to internet namespace
-rw-r--r--lib/internet.js15
-rw-r--r--test/internet.unit.js8
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/internet.js b/lib/internet.js
index db706dea..cc3f69ad 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 e4391453..2821c1b7 100644
--- a/test/internet.unit.js
+++ b/test/internet.unit.js
@@ -134,6 +134,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');