Skip to content

Commit

Permalink
new fun test and doc updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Waqas-Jani committed Mar 16, 2024
1 parent e25e770 commit 9632cfb
Show file tree
Hide file tree
Showing 7 changed files with 404 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ or relevant libraries. Common operations include concatenation, searching, repla
| ✔✔ `JStr.padLeft` | Pads the string on the left side with a specified character to a specified length. | [Documentation](docs/PadLeft.md) |
| ✔✔ `JStr.padRight` | Pads the string on the right side with a specified character to a specified length. | [Documentation](docs/PadRight.md) |
| ✔✔ `JStr.password` | Generates a password string. | [Documentation](docs/Password.md) |
|`JStr.plural` | Converts the string to plural form. | [Documentation](docs/Plural.md) |
|`JStr.pluralStudly` | Converts the string to plural studly form. | [Documentation](docs/PluralStudly.md) |
| `JStr.plural` | Converts the string to plural form. | [Documentation](docs/Plural.md) |
| `JStr.pluralStudly` | Converts the string to plural studly form. | [Documentation](docs/PluralStudly.md) |
| ✔✔ `JStr.position` | Finds the position of the first occurrence of a substring in the string. | [Documentation](docs/Position.md) |
| ✔✔ `JStr.random` | Generates a random string. | [Documentation](docs/Random.md) |
| ✔✔ `JStr.remove` | Removes a specified substring from the string. | [Documentation](docs/Remove.md) |
Expand All @@ -115,7 +115,7 @@ or relevant libraries. Common operations include concatenation, searching, repla
| ✔✔ `JStr.replaceLast` | Replaces the last occurrence of a specified substring with another substring. | [Documentation](docs/ReplaceLast.md) |
| ✔✔ `JStr.rtrim` | Removes whitespace from the end of the string. | [Documentation](docs/Rtrim.md) |
| ✔✔ `JStr.reverse` | Reverses the characters of the string. | [Documentation](docs/Reverse.md) |
|`JStr.singular` | Converts the string to singular form. | [Documentation](docs/Singular.md) |
| `JStr.singular` | Converts the string to singular form. | [Documentation](docs/Singular.md) |
|`JStr.slug` | Converts the string to a URL-friendly slug. | [Documentation](docs/Slug.md) |
| ✔✔ `JStr.snake` | Converts the string to snake case. | [Documentation](docs/Snake.md) |
|`JStr.squish` | Reduces multiple consecutive whitespace characters to a single space. | [Documentation](docs/Squish.md) |
Expand Down Expand Up @@ -196,7 +196,7 @@ clarity and conciseness in your code.
| ✔✔ `padLeft` | Pads the string on the left side with a specified character to a specified length. | [Documentation](docs/PadLeft.md) |
| ✔✔ `padRight` | Pads the string on the right side with a specified character to a specified length. | [Documentation](docs/PadRight.md) |
|`pipe` | Passes the string to a callback and returns the result. | [Documentation](docs/Pipe.md) |
|`plural` | Converts the string to plural form. | [Documentation](docs/Plural.md) |
| `plural` | Converts the string to plural form. | [Documentation](docs/Plural.md) |
| ✔✔ `position` | Finds the position of the first occurrence of a substring in the string. | [Documentation](docs/Position.md) |
|`prepend` | Prepends a string or an array of strings to the beginning of the current string. | [Documentation](docs/Prepend.md) |
| ✔✔ `remove` | Removes a specified substring from the string. | [Documentation](docs/Remove.md) |
Expand All @@ -209,15 +209,15 @@ clarity and conciseness in your code.
| ✔✔ `reverse` | Reverses the characters of the string. | [Documentation](docs/Reverse.md) |
| ✔✔ `rtrim` | Removes whitespace from the end of the string. | [Documentation](docs/Rtrim.md) |
|`scan` | Returns an array of all occurrences of a regular expression pattern in the string. | [Documentation](docs/Scan.md) |
|`singular` | Converts the string to singular form. | [Documentation](docs/Singular.md) |
| `singular` | Converts the string to singular form. | [Documentation](docs/Singular.md) |
|`slug` | Converts the string to a URL-friendly slug. | [Documentation](docs/Slug.md) |
| ✔✔ `snake` | Converts the string to snake case. | [Documentation](docs/Snake.md) |
|`split` | Splits the string by a specified delimiter and returns an array of the parts. | [Documentation](docs/Split.md) |
|`squish` | Reduces multiple consecutive whitespace characters to a single space. | [Documentation](docs/Squish.md) |
| ✔✔ `start` | Adds a specified prefix to the beginning of the string. | [Documentation](docs/Start.md) |
|`startsWith` | Checks if the string starts with a specified prefix. | [Documentation](docs/StartsWith.md) |
| ✔✔ `studly` | Converts the string to studly case. | [Documentation](docs/Studly.md) |
| `pluralStudy` | Converts the string to studly case. | [Documentation](docs/Studly.md) |
|`pluralStudly` | Converts the string to studly case. | [Documentation](docs/PluralStudly.md) |
|`substr` | Returns a substring of the string starting from a specified position. | [Documentation](docs/Substr.md) |
|`substrCount` | Counts the number of occurrences of a substring in the string. | [Documentation](docs/SubstrCount.md) |
|`substrReplace` | Replaces a portion of the string with a specified substring. | [Documentation](docs/SubstrReplace.md) |
Expand Down
40 changes: 40 additions & 0 deletions docs/Plural.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# plural

### Example#1

```javascript
import JStr from "@akcybex/jstr";

const result = JStr.plural("man");
console.log(result); // Outputs: 'men'
```

### Example#2

```javascript
import JStr from "@akcybex/jstr";

const result = JStr.plural("dog");

console.log(result); // Outputs: 'dogs'
```

### Example#3

```javascript
import JStr from "@akcybex/jstr";

const result = JStr.of("foot").plural().toString();

console.log(result); // Outputs: 'feet'
```

### Example#4

```javascript
import JStr from "@akcybex/jstr";

const result = JStr.of("fish").plural().toString();

console.log(result); // Outputs: 'fish'
```
40 changes: 40 additions & 0 deletions docs/PluralStudly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# pluralStudly

### Example#1

```javascript
import JStr from "@akcybex/jstr";

const result = JStr.pluralStudly("manwoman");
console.log(result); // Outputs: 'manwomen'
```

### Example#2

```javascript
import JStr from "@akcybex/jstr";

const result = JStr.pluralStudly("Babyboy");

console.log(result); // Outputs: 'Babyboys'
```

### Example#3

```javascript
import JStr from "@akcybex/jstr";

const result = JStr.of("forkKnife").pluralStudly().toString();

console.log(result); // Outputs: 'forkKnives'
```

### Example#4

```javascript
import JStr from "@akcybex/jstr";

const result = JStr.of("fish").pluralStudly().toString();

console.log(result); // Outputs: 'fish'
```
40 changes: 40 additions & 0 deletions docs/Singular.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# singular

### Example#1

```javascript
import JStr from "@akcybex/jstr";

const result = JStr.singular("men");
console.log(result); // Outputs: 'man'
```

### Example#2

```javascript
import JStr from "@akcybex/jstr";

const result = JStr.singular("dogs");

console.log(result); // Outputs: 'dog'
```

### Example#3

```javascript
import JStr from "@akcybex/jstr";

const result = JStr.of("feet").singular().toString();

console.log(result); // Outputs: 'foot'
```

### Example#4

```javascript
import JStr from "@akcybex/jstr";

const result = JStr.of("fist").singular().toString();

console.log(result); // Outputs: 'fish'
```
109 changes: 109 additions & 0 deletions tests/plural.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import JStr from "../src/main.ts";

/**
* The plural method converts the given string to plural:
*/

describe('plural JStr static function', () => {
test('should call plural with the provided value', () => {
const input = 'dog';
expect(JStr.plural(input)).toBe('dogs');
});
test('should plural with the men value', () => {
const input = 'man';
expect(JStr.plural(input)).toBe('men');
});

test('should plural with the Crocodile value', () => {
const input = 'Crocodile';
expect(JStr.plural(input)).toBe('Crocodiles');
});

test('should plural ies plural with the Baby value', () => {
const input = 'Baby';
expect(JStr.plural(input)).toBe('Babies');
});

test('should plural ies plural with the Rally value', () => {
const input = 'Rally';
expect(JStr.plural(input)).toBe('Rallies');
});

test('should plural with the Knife value', () => {
const input = 'Knife';
expect(JStr.plural(input)).toBe('Knives');
});
test('should plural with the Leaf value', () => {
const input = 'Leaf';
expect(JStr.plural(input)).toBe('Leaves');
});

test('should plural with the Child value', () => {
const input = 'Child';
expect(JStr.plural(input)).toBe('Children');
});
test('should plural with the Foot value', () => {
const input = 'Foot';
expect(JStr.plural(input)).toBe('Feet');
});

test('should plural with the Fish value', () => {
const input = 'Fish';
expect(JStr.plural(input)).toBe('Fish');
});



});

describe('plural JStr dynamic function', () => {
test('should call plural with the provided value', () => {
const input = 'dog';
expect(JStr.of(input).plural().toString()).toBe('dogs');
});
test('should plural with the men value', () => {
const input = 'man';
expect(JStr.of(input).plural().toString()).toBe('men');
});

test('should plural with the Crocodile value', () => {
const input = 'Crocodile';
expect(JStr.of(input).plural().toString()).toBe('Crocodiles');
});

test('should plural ies plural with the Baby value', () => {
const input = 'Baby';
expect(JStr.of(input).plural().toString()).toBe('Babies');
});

test('should plural ies plural with the Rally value', () => {
const input = 'Rally';
expect(JStr.of(input).plural().toString()).toBe('Rallies');
});

test('should plural with the Knife value', () => {
const input = 'Knife';
expect(JStr.of(input).plural().toString()).toBe('Knives');
});
test('should plural with the Leaf value', () => {
const input = 'Leaf';
expect(JStr.of(input).plural().toString()).toBe('Leaves');
});

test('should plural with the Child value', () => {
const input = 'Child';
expect(JStr.of(input).plural().toString()).toBe('Children');
});
test('should plural with the Foot value', () => {
const input = 'Foot';
expect(JStr.of(input).plural().toString()).toBe('Feet');
});

test('should plural with the Fish value', () => {
const input = 'Fish';
expect(JStr.of(input).plural().toString()).toBe('Fish');
});



});
60 changes: 60 additions & 0 deletions tests/pluralStudly.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import JStr from "../src/main.ts";

/**
* The pluralStudly method converts a singular word string formatted in studly caps case to its plural form
*/

describe('plural JStr static function', () => {
test('should call plural with the provided value', () => {
const input = 'dogcat';
expect(JStr.pluralStudly(input)).toBe('dogcats');
});
test('should plural with the men value', () => {
const input = 'manwoman';
expect(JStr.plural(input)).toBe('manwomen');
});

test('should plural of the dog value', () => {
const input = 'catdog';
expect(JStr.pluralStudly(input)).toBe('catdogs');
});

test('should plural ies plural with the Baby value', () => {
const input = 'Babyboy';
expect(JStr.plural(input)).toBe('Babyboys');
});

test('should plural with the Knife value', () => {
const input = 'forkKnife';
expect(JStr.plural(input)).toBe('forkKnives');
});

});

describe('plural JStr dynamic function', () => {
test('should call plural with the provided value', () => {
const input = 'dogcat';
expect(JStr.of(input).pluralStudly().toString()).toBe('dogcats');
});
test('should plural with the men value', () => {
const input = 'manwoman';
expect(JStr.of(input).pluralStudly().toString()).toBe('manwomen');
});

test('should plural of the dog value', () => {
const input = 'catdog';
expect(JStr.of(input).pluralStudly().toString()).toBe('catdogs');
});

test('should plural ies plural with the Baby value', () => {
const input = 'Babyboy';
expect(JStr.of(input).pluralStudly().toString()).toBe('Babyboys');
});

test('should plural with the Knife value', () => {
const input = 'forkKnife';
expect(JStr.of(input).pluralStudly().toString()).toBe('`forkKnives`');
});

});

Loading

0 comments on commit 9632cfb

Please sign in to comment.