aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLeyla Jähnig <[email protected]>2022-10-14 23:54:31 +0200
committerGitHub <[email protected]>2022-10-14 21:54:31 +0000
commita90f2fe65c705a5593215b0a35945b77c1d575f1 (patch)
treebec933c9817ff19c05654a9376333c3c74a39316 /test
parent9c1437d6034ef5537c079746761c4c71347f768b (diff)
downloadfaker-a90f2fe65c705a5593215b0a35945b77c1d575f1.tar.xz
faker-a90f2fe65c705a5593215b0a35945b77c1d575f1.zip
feat(internet)!: ip now returns ipv4 and ipv6 (#1059)
Diffstat (limited to 'test')
-rw-r--r--test/__snapshots__/internet.spec.ts.snap6
-rw-r--r--test/internet.spec.ts12
2 files changed, 14 insertions, 4 deletions
diff --git a/test/__snapshots__/internet.spec.ts.snap b/test/__snapshots__/internet.spec.ts.snap
index 697bc613..d2c43911 100644
--- a/test/__snapshots__/internet.spec.ts.snap
+++ b/test/__snapshots__/internet.spec.ts.snap
@@ -34,7 +34,7 @@ exports[`internet > 42 > httpStatusCode > noArgs 1`] = `207`;
exports[`internet > 42 > httpStatusCode > with options 1`] = `410`;
-exports[`internet > 42 > ip 1`] = `"95.203.243.46"`;
+exports[`internet > 42 > ip 1`] = `"cf2b:c992:7210:7d59:2ba0:0fbd:f302:f294"`;
exports[`internet > 42 > ipv4 1`] = `"95.203.243.46"`;
@@ -94,7 +94,7 @@ exports[`internet > 1211 > httpStatusCode > noArgs 1`] = `505`;
exports[`internet > 1211 > httpStatusCode > with options 1`] = `429`;
-exports[`internet > 1211 > ip 1`] = `"237.117.228.199"`;
+exports[`internet > 1211 > ip 1`] = `"117.228.199.57"`;
exports[`internet > 1211 > ipv4 1`] = `"237.117.228.199"`;
@@ -154,7 +154,7 @@ exports[`internet > 1337 > httpStatusCode > noArgs 1`] = `205`;
exports[`internet > 1337 > httpStatusCode > with options 1`] = `407`;
-exports[`internet > 1337 > ip 1`] = `"67.143.40.54"`;
+exports[`internet > 1337 > ip 1`] = `"8234:8705:3894:5f4b:41c6:1a52:bf27:dccc"`;
exports[`internet > 1337 > ipv4 1`] = `"67.143.40.54"`;
diff --git a/test/internet.spec.ts b/test/internet.spec.ts
index 1dbccc23..cbbf2745 100644
--- a/test/internet.spec.ts
+++ b/test/internet.spec.ts
@@ -368,11 +368,21 @@ describe('internet', () => {
});
describe('ip()', () => {
- it('should return a random IPv4 address with four parts', () => {
+ it('should return a random IPv4 or IPv6 address', () => {
const ip = faker.internet.ip();
expect(ip).toBeTruthy();
expect(ip).toBeTypeOf('string');
+ expect(ip).toSatisfy(validator.isIP);
+ });
+ });
+
+ describe('ipv4()', () => {
+ it('should return a random IPv4 with four parts', () => {
+ const ip = faker.internet.ipv4();
+
+ expect(ip).toBeTruthy();
+ expect(ip).toBeTypeOf('string');
expect(ip).toSatisfy((value: string) => validator.isIP(value, 4));
const parts = ip.split('.');