aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDivisionByZero <[email protected]>2023-01-29 17:28:13 +0100
committerGitHub <[email protected]>2023-01-29 16:28:13 +0000
commit7bc4a099558318c690d0101dc4765c08dee2c840 (patch)
treef61296db6953c65c332210798ca34a755583a4fc
parentcec78775e995ece1e6004e8aece6304820126296 (diff)
downloadfaker-7bc4a099558318c690d0101dc4765c08dee2c840.tar.xz
faker-7bc4a099558318c690d0101dc4765c08dee2c840.zip
refactor(string): rename `special` to `symbol` (#1789)
-rw-r--r--src/modules/string/index.ts13
-rw-r--r--test/__snapshots__/string.spec.ts.snap42
-rw-r--r--test/string.spec.ts10
3 files changed, 34 insertions, 31 deletions
diff --git a/src/modules/string/index.ts b/src/modules/string/index.ts
index 6184c043..8f62788a 100644
--- a/src/modules/string/index.ts
+++ b/src/modules/string/index.ts
@@ -740,20 +740,23 @@ export class StringModule {
}
/**
- * Returns a string containing only special characters.
+ * Returns a string containing only special characters from the following list:
+ * ```txt
+ * ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
+ * ```
*
* @param length Length of the generated string. Defaults to `1`.
* @param length.min The minimum number of special characters to generate.
* @param length.max The maximum number of special characters to generate.
*
* @example
- * faker.string.special() // '$'
- * faker.string.special(5) // '#*!.~'
- * faker.string.special({ min: 5, max: 10 }) // ')|@*>^+'
+ * faker.string.symbol() // '$'
+ * faker.string.symbol(5) // '#*!.~'
+ * faker.string.symbol({ min: 5, max: 10 }) // ')|@*>^+'
*
* @since 8.0.0
*/
- special(
+ symbol(
length:
| number
| {
diff --git a/test/__snapshots__/string.spec.ts.snap b/test/__snapshots__/string.spec.ts.snap
index 61245b7b..07e0e4bb 100644
--- a/test/__snapshots__/string.spec.ts.snap
+++ b/test/__snapshots__/string.spec.ts.snap
@@ -150,19 +150,19 @@ exports[`string > 42 > sample > with length parameter 5`] = `"\\"&{dn"`;
exports[`string > 42 > sample > with length range 1`] = `"ky2eiXX/J/*&Kq"`;
-exports[`string > 42 > special > noArgs 1`] = `","`;
+exports[`string > 42 > symbol > noArgs 1`] = `","`;
-exports[`string > 42 > special > with length parameter 1`] = `",^}&\\\\"`;
+exports[`string > 42 > symbol > with length parameter 1`] = `",^}&\\\\"`;
-exports[`string > 42 > special > with length parameter 2`] = `"]>>%/"`;
+exports[`string > 42 > symbol > with length parameter 2`] = `"]>>%/"`;
-exports[`string > 42 > special > with length parameter 3`] = `"%$\\"/\`"`;
+exports[`string > 42 > symbol > with length parameter 3`] = `"%$\\"/\`"`;
-exports[`string > 42 > special > with length parameter 4`] = `"+>%[?"`;
+exports[`string > 42 > symbol > with length parameter 4`] = `"+>%[?"`;
-exports[`string > 42 > special > with length parameter 5`] = `"!\\"~\\\\_"`;
+exports[`string > 42 > symbol > with length parameter 5`] = `"!\\"~\\\\_"`;
-exports[`string > 42 > special > with length range 1`] = `"^}&\\\\]>>%/%$\\"/\`"`;
+exports[`string > 42 > symbol > with length range 1`] = `"^}&\\\\]>>%/%$\\"/\`"`;
exports[`string > 42 > uuid 1`] = `"5cf2bc99-2721-407d-992b-a00fbdf302f2"`;
@@ -324,19 +324,19 @@ exports[`string > 1211 > sample > with length parameter 5`] = `"h^]dn"`;
exports[`string > 1211 > sample > with length range 1`] = `"Kti5-}$_/\`4hHA0afl\\"h"`;
-exports[`string > 1211 > special > noArgs 1`] = `"|"`;
+exports[`string > 1211 > symbol > noArgs 1`] = `"|"`;
-exports[`string > 1211 > special > with length parameter 1`] = `"|/{]("`;
+exports[`string > 1211 > symbol > with length parameter 1`] = `"|/{]("`;
-exports[`string > 1211 > special > with length parameter 2`] = `"%~\\"@&"`;
+exports[`string > 1211 > symbol > with length parameter 2`] = `"%~\\"@&"`;
-exports[`string > 1211 > special > with length parameter 3`] = `"@'].,"`;
+exports[`string > 1211 > symbol > with length parameter 3`] = `"@'].,"`;
-exports[`string > 1211 > special > with length parameter 4`] = `"&[\\\\_!"`;
+exports[`string > 1211 > symbol > with length parameter 4`] = `"&[\\\\_!"`;
-exports[`string > 1211 > special > with length parameter 5`] = `"]@?\\\\_"`;
+exports[`string > 1211 > symbol > with length parameter 5`] = `"]@?\\\\_"`;
-exports[`string > 1211 > special > with length range 1`] = `"/{](%~\\"@&@'].,&[\\\\_!]"`;
+exports[`string > 1211 > symbol > with length range 1`] = `"/{](%~\\"@&@'].,&[\\\\_!]"`;
exports[`string > 1211 > uuid 1`] = `"e7ec32f0-a2a3-4c65-abbd-0caabde64dfd"`;
@@ -498,19 +498,19 @@ exports[`string > 1337 > sample > with length parameter 5`] = `"D)[B,"`;
exports[`string > 1337 > sample > with length range 1`] = `"U/4:SK$>6QX9"`;
-exports[`string > 1337 > special > noArgs 1`] = `")"`;
+exports[`string > 1337 > symbol > noArgs 1`] = `")"`;
-exports[`string > 1337 > special > with length parameter 1`] = `")<&')"`;
+exports[`string > 1337 > symbol > with length parameter 1`] = `")<&')"`;
-exports[`string > 1337 > special > with length parameter 2`] = `"</\\"+("`;
+exports[`string > 1337 > symbol > with length parameter 2`] = `"</\\"+("`;
-exports[`string > 1337 > special > with length parameter 3`] = `";=)+~"`;
+exports[`string > 1337 > symbol > with length parameter 3`] = `";=)+~"`;
-exports[`string > 1337 > special > with length parameter 4`] = `")\\\\*$^"`;
+exports[`string > 1337 > symbol > with length parameter 4`] = `")\\\\*$^"`;
-exports[`string > 1337 > special > with length parameter 5`] = `"-$?,%"`;
+exports[`string > 1337 > symbol > with length parameter 5`] = `"-$?,%"`;
-exports[`string > 1337 > special > with length range 1`] = `"<&')</\\"+(;=)"`;
+exports[`string > 1337 > symbol > with length range 1`] = `"<&')</\\"+(;=)"`;
exports[`string > 1337 > uuid 1`] = `"48234870-5389-445f-8b41-c61a52bf27dc"`;
diff --git a/test/string.spec.ts b/test/string.spec.ts
index 5c256a32..c3da56f1 100644
--- a/test/string.spec.ts
+++ b/test/string.spec.ts
@@ -119,7 +119,7 @@ describe('string', () => {
.it('with length range', { min: 13, max: 37 });
});
- t.describe('special', (t) => {
+ t.describe('symbol', (t) => {
t.it('noArgs')
.itRepeated('with length parameter', 5, 5)
.it('with length range', { min: 10, max: 20 });
@@ -782,14 +782,14 @@ describe('string', () => {
describe('special', () => {
it('should return a value of type string with default length of 1', () => {
- const actual = faker.string.special();
+ const actual = faker.string.symbol();
expect(actual).toBeTypeOf('string');
expect(actual).toHaveLength(1);
});
it('should return an empty string when length is negative', () => {
- const actual = faker.string.special(
+ const actual = faker.string.symbol(
faker.number.int({ min: -1000, max: -1 })
);
@@ -799,13 +799,13 @@ describe('string', () => {
it('should return string of designated length', () => {
const length = 87;
- const actual = faker.string.special(length);
+ const actual = faker.string.symbol(length);
expect(actual).toHaveLength(length);
});
it('should return string with a length within a given range', () => {
- const actual = faker.string.special({ min: 10, max: 20 });
+ const actual = faker.string.symbol({ min: 10, max: 20 });
expect(actual.length).toBeGreaterThanOrEqual(10);
expect(actual.length).toBeLessThanOrEqual(20);