Skip to content

Commit ff4a6e3

Browse files
committed
add tests for passing in functions and objects
1 parent a5b93d3 commit ff4a6e3

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,48 @@ test('findAndReplace', function (t) {
166166
'should ignore from options'
167167
)
168168

169+
t.deepEqual(
170+
findAndReplace(
171+
h('p', [
172+
h('span', 'visible text'),
173+
h('span', {
174+
text: 'hidden text',
175+
style: 'font-size:1px;display:none;line-height:1px;'
176+
})
177+
]),
178+
'text',
179+
'TEXT',
180+
{
181+
ignore: function (node) {
182+
return /display:\s*none/.test(node.properties.style)
183+
}
184+
}
185+
),
186+
h('p', [
187+
h('span', ['visible ', 'TEXT']),
188+
h('span', {
189+
text: 'hidden text',
190+
style: 'font-size:1px;display:none;line-height:1px;'
191+
})
192+
]),
193+
'should ignore using function'
194+
)
195+
196+
t.deepEqual(
197+
findAndReplace(
198+
h('p', [h('span', 'text'), h('sup', 'text')]),
199+
'text',
200+
'TEXT',
201+
{
202+
ignore: {
203+
tagName: 'sup'
204+
}
205+
}
206+
),
207+
h('p', [h('span', 'TEXT'), h('sup', 'text')]),
208+
'should ignore using objects'
209+
)
210+
169211
t.deepEqual(
170212
findAndReplace(h('p', 'Some emphasis, importance, and code.'), {
171213
importance: function (match) {

0 commit comments

Comments
 (0)