react-string-replace-recursively
Advanced tools
Comparing version 0.1.22 to 0.1.23
{ | ||
"name": "react-string-replace-recursively", | ||
"version": "0.1.22", | ||
"version": "0.1.23", | ||
"description": "replace strings that match a particular pattern with a React Component, recursively", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -32,5 +32,6 @@ # React String Replace Recursively | ||
<ParentComponent> | ||
["I appreciate a good", | ||
["I appreciate a good ", | ||
<Link to={"tags/#chairback"}> | ||
[<span className='search-term-match'>chair</span>, | ||
["#", | ||
<span className='search-term-match'>chair</span>, | ||
"back"] | ||
@@ -37,0 +38,0 @@ </Link>, |
@@ -15,2 +15,6 @@ const expect = require('chai').expect; | ||
const _searchTermFn = function (rawText, processed) { | ||
return {searchTerm: processed} | ||
} | ||
const config = { | ||
@@ -26,6 +30,10 @@ 'url': { | ||
matcherFn: _hashTagFn | ||
}, | ||
'searchTerm': { | ||
pattern: /(chair)/ig, | ||
matcherFn: _searchTermFn | ||
} | ||
} | ||
it('works in trivial case', function () { | ||
it('works with trivial inputText', function () { | ||
const inputText = '' | ||
@@ -37,3 +45,3 @@ const result = patternReplacerCreator(config)(inputText) | ||
it('works in simple case', function () { | ||
it('works with one pattern', function () { | ||
const inputText = "how #great this #is" | ||
@@ -44,2 +52,15 @@ const result = patternReplacerCreator(config)(inputText) | ||
}) | ||
it('recursively replaces a pattern that occurs within another', function () { | ||
const inputText = "I appreciate a good #chairback I must say" | ||
const result = patternReplacerCreator(config)(inputText) | ||
const expected = ["I appreciate a good ", | ||
{hashtag: ["#", {searchTerm: ["chair"]}, "back"]}, | ||
" I must say"] | ||
expect(result).to.deep.equal(expected) | ||
}) | ||
it('ignores a pattern that occurs within another when config indicates this should be done', function () { | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14895
179
125