aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Cheng <[email protected]>2022-10-26 16:42:17 -0400
committerGitHub <[email protected]>2022-10-26 22:42:17 +0200
commit09e835664add0a342dd089f31bbae7d880198493 (patch)
tree14f6f85c6d9fa10cbeba9ef96d405e05a3a3d843 /test
parent64b031a9e385d1461b2c158abfa1851ba11a8397 (diff)
downloadfaker-09e835664add0a342dd089f31bbae7d880198493.tar.xz
faker-09e835664add0a342dd089f31bbae7d880198493.zip
feat(internet): add options to url() (#1480)
Diffstat (limited to 'test')
-rw-r--r--test/__snapshots__/internet.spec.ts.snap18
-rw-r--r--test/internet.spec.ts27
2 files changed, 41 insertions, 4 deletions
diff --git a/test/__snapshots__/internet.spec.ts.snap b/test/__snapshots__/internet.spec.ts.snap
index d2c43911..500f8d8c 100644
--- a/test/__snapshots__/internet.spec.ts.snap
+++ b/test/__snapshots__/internet.spec.ts.snap
@@ -52,7 +52,11 @@ exports[`internet > 42 > port 1`] = `24545`;
exports[`internet > 42 > protocol 1`] = `"http"`;
-exports[`internet > 42 > url 1`] = `"http://staid-veil.biz"`;
+exports[`internet > 42 > url > noArgs 1`] = `"https://staid-veil.biz"`;
+
+exports[`internet > 42 > url > with slash appended 1`] = `"https://hasty-shin.org/"`;
+
+exports[`internet > 42 > url > without slash appended and with http protocol 1`] = `"http://hasty-shin.org"`;
exports[`internet > 42 > userAgent 1`] = `"Mozilla/5.0 (Windows; U; Windows NT 6.2) AppleWebKit/538.0.2 (KHTML, like Gecko) Chrome/29.0.815.0 Safari/538.0.2"`;
@@ -112,7 +116,11 @@ exports[`internet > 1211 > port 1`] = `60851`;
exports[`internet > 1211 > protocol 1`] = `"https"`;
-exports[`internet > 1211 > url 1`] = `"https://jubilant-temple.net"`;
+exports[`internet > 1211 > url > noArgs 1`] = `"https://jubilant-temple.net/"`;
+
+exports[`internet > 1211 > url > with slash appended 1`] = `"https://vibrant-infix.org/"`;
+
+exports[`internet > 1211 > url > without slash appended and with http protocol 1`] = `"http://vibrant-infix.org"`;
exports[`internet > 1211 > userAgent 1`] = `"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6 rv:3.0; PT) AppleWebKit/538.2.0 (KHTML, like Gecko) Version/4.1.0 Safari/538.2.0"`;
@@ -172,7 +180,11 @@ exports[`internet > 1337 > port 1`] = `17172`;
exports[`internet > 1337 > protocol 1`] = `"http"`;
-exports[`internet > 1337 > url 1`] = `"http://neat-chopstick.biz"`;
+exports[`internet > 1337 > url > noArgs 1`] = `"https://neat-chopstick.biz"`;
+
+exports[`internet > 1337 > url > with slash appended 1`] = `"https://fair-migration.com/"`;
+
+exports[`internet > 1337 > url > without slash appended and with http protocol 1`] = `"http://fair-migration.com"`;
exports[`internet > 1337 > userAgent 1`] = `"Mozilla/5.0 (Windows; U; Windows NT 6.1) AppleWebKit/532.0.0 (KHTML, like Gecko) Chrome/13.0.832.0 Safari/532.0.0"`;
diff --git a/test/internet.spec.ts b/test/internet.spec.ts
index cbbf2745..02f0edaa 100644
--- a/test/internet.spec.ts
+++ b/test/internet.spec.ts
@@ -16,7 +16,6 @@ describe('internet', () => {
'avatar',
'protocol',
'httpMethod',
- 'url',
'domainName',
'domainSuffix',
'domainWord',
@@ -61,6 +60,15 @@ describe('internet', () => {
t.describe('emoji', (t) => {
t.it('noArgs').it('with options', { types: ['nature'] });
});
+
+ t.describe('url', (t) => {
+ t.it('noArgs')
+ .it('with slash appended', { appendSlash: true })
+ .it('without slash appended and with http protocol', {
+ appendSlash: false,
+ protocol: 'http',
+ });
+ });
});
describe(`random seeded tests for seed ${faker.seed()}`, () => {
@@ -325,6 +333,23 @@ describe('internet', () => {
expect(url).toBeTypeOf('string');
expect(url).toSatisfy(validator.isURL);
});
+
+ it('should return a valid url with slash appended at the end', () => {
+ const url = faker.internet.url({ appendSlash: true });
+
+ expect(url).toBeTruthy();
+ expect(url).toBeTypeOf('string');
+ expect(url).toSatisfy(validator.isURL);
+ expect(url.endsWith('/')).toBeTruthy();
+ });
+
+ it('should return a valid url with given protocol', () => {
+ const url = faker.internet.url({ protocol: 'http' });
+
+ expect(url).toBeTruthy();
+ expect(url).toBeTypeOf('string');
+ expect(url).toSatisfy(validator.isURL);
+ });
});
describe('domainName()', () => {