Skip to content

Commit bf92853

Browse files
committed
Fix coverage
1 parent 92bcd71 commit bf92853

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"tape": "^5.0.0",
4848
"type-coverage": "^2.0.0",
4949
"typescript": "^4.0.0",
50-
"xo": "^0.39.0"
50+
"xo": "^0.42.0"
5151
},
5252
"scripts": {
5353
"prepack": "npm run build && npm run format",

test.js

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ test('findAndReplace', (t) => {
4444
findAndReplace(
4545
create(),
4646
/em(\w+)is/,
47-
(/** @type {string} */ _, /** @type {string} */ $1) => {
48-
return '[' + $1 + ']'
49-
}
47+
(/** @type {string} */ _, /** @type {string} */ $1) => '[' + $1 + ']'
5048
),
5149
h('p', [
5250
'Some ',
@@ -61,9 +59,21 @@ test('findAndReplace', (t) => {
6159
)
6260

6361
t.deepEqual(
64-
findAndReplace(create(), 'emphasis', () => {
65-
return h('a', h('b', 'c'))
66-
}),
62+
findAndReplace(create(), 'emphasis', () => ''),
63+
h('p', [
64+
'Some ',
65+
h('em'),
66+
', ',
67+
h('strong', 'importance'),
68+
', and ',
69+
h('code', 'code'),
70+
'.'
71+
]),
72+
'should work when given `replace` returns an empty string'
73+
)
74+
75+
t.deepEqual(
76+
findAndReplace(create(), 'emphasis', () => h('a', h('b', 'c'))),
6777
h('p', [
6878
'Some ',
6979
h('em', h('a', h('b', 'c'))),
@@ -76,6 +86,20 @@ test('findAndReplace', (t) => {
7686
'should work when given `replace` returns a node'
7787
)
7888

89+
t.deepEqual(
90+
findAndReplace(create(), 'emphasis', () => [h('a'), h('b', 'c')]),
91+
h('p', [
92+
'Some ',
93+
h('em', [h('a'), h('b', 'c')]),
94+
', ',
95+
h('strong', 'importance'),
96+
', and ',
97+
h('code', 'code'),
98+
'.'
99+
]),
100+
'should work when given `replace` returns a list of nodes'
101+
)
102+
79103
t.deepEqual(
80104
findAndReplace(create(), [
81105
['emphasis', '!!!'],
@@ -233,9 +257,7 @@ test('findAndReplace', (t) => {
233257
)
234258

235259
t.deepEqual(
236-
findAndReplace(create(), 'and', () => {
237-
return h('script', 'alert(1)')
238-
}),
260+
findAndReplace(create(), 'and', () => h('script', 'alert(1)')),
239261
h('p', [
240262
'Some ',
241263
h('em', 'emphasis'),

0 commit comments

Comments
 (0)