-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from rudashi/stringable-40
Resolved #40
- Loading branch information
Showing
8 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
const {Stringable} = require('../src/Stringable'); | ||
const {Str} = require('../src/Str'); | ||
const {replaceEnd} = require('../src/methods'); | ||
|
||
test.each([ | ||
['World', 'Laravel', 'Hello World', 'Hello Laravel'], | ||
['Hello', 'Laravel', 'Hello World', 'Hello World'], | ||
['bar', 'qux', 'foobar foobar', 'foobar fooqux'], | ||
['bar?', 'qux?', 'foo/bar? foo/bar?', 'foo/bar? foo/qux?'], | ||
['bar', '', 'foobar foobar', 'foobar foo'], | ||
['xxx', 'yyy', 'foobar foobar', 'foobar foobar'], | ||
['', 'yyy', 'foobar foobar', 'foobar foobar'], | ||
['xxx', 'yyy', 'fooxxx foobar', 'fooxxx foobar'], | ||
['ö', 'xxx', 'Malmö Jönköping', 'Malmö Jönköping'], | ||
['öping', 'yyy', 'Malmö Jönköping', 'Malmö Jönkyyy'], | ||
])('.replaceEnd from %p search %p and replace with %p then returns %p', | ||
/** | ||
* @param {string} search | ||
* @param {string} replace | ||
* @param {string} string | ||
* @param {string} expected | ||
*/ | ||
(search, replace, string, expected) => { | ||
expect(Stringable.of(string).replaceEnd(search, replace).toString()) | ||
.toBe(expected); | ||
|
||
expect(Str.replaceEnd(search, replace, string)) | ||
.toBe(expected); | ||
|
||
expect(replaceEnd(search, replace, string)) | ||
.toBe(expected); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
const {Stringable} = require('../src/Stringable'); | ||
const {Str} = require('../src/Str'); | ||
const {replaceStart} = require('../src/methods'); | ||
|
||
test.each([ | ||
['Hello', 'Laravel', 'Hello World', 'Laravel World'], | ||
['World', 'Laravel', 'Hello World', 'Hello World'], | ||
['bar', 'qux', 'foobar foobar', 'foobar foobar'], | ||
['bar?', 'qux?', 'foo/bar? foo/bar?', 'foo/bar? foo/bar?'], | ||
['foo', 'qux', 'foobar foobar', 'quxbar foobar'], | ||
['foo/bar?', 'qux?', 'foo/bar? foo/bar?', 'qux? foo/bar?'], | ||
['foo', '', 'foobar foobar', 'bar foobar'], | ||
[0, '1', '0', '1'], | ||
['Jö', 'xxx', 'Jönköping Malmö', 'xxxnköping Malmö'], | ||
['', 'yyy', 'Jönköping Malmö', 'Jönköping Malmö'], | ||
])('.replaceEnd from %p search %p and replace with %p then returns %p', | ||
/** | ||
* @param {string} search | ||
* @param {string} replace | ||
* @param {string} subject | ||
* @param {string} expected | ||
*/ | ||
(search, replace, subject, expected) => { | ||
expect(Stringable.of(subject).replaceStart(search, replace).toString()) | ||
.toBe(expected); | ||
|
||
expect(Str.replaceStart(search, replace, subject)) | ||
.toBe(expected); | ||
|
||
expect(replaceStart(search, replace, subject)) | ||
.toBe(expected); | ||
} | ||
); |