Skip to content

Commit f1394c4

Browse files
fix(block-replacer): update test to reflect preloaded-content behavior
When both srcPath and content are provided, content is now used as preloaded file contents instead of throwing an error. Update the test to match the new intentional behavior. Co-authored-by: David Wells <DavidWells@users.noreply.github.com>
1 parent 0b8a16b commit f1394c4

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

packages/block-replacer/test/index.test.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,18 @@ test content
192192
assert.is(result.isChanged, false)
193193
})
194194

195-
test('should handle both srcPath and content error', async () => {
195+
test('should handle both srcPath and content using preloaded content', async () => {
196196
/** @type {ProcessFileOptions} */
197197
const options = {
198-
srcPath: '/some/path',
199-
content: 'some content',
198+
srcPath: '/some/nonexistent/path',
199+
content: 'preloaded content',
200200
dryRun: true
201201
}
202202

203-
try {
204-
await processFile(options)
205-
assert.unreachable('Should have thrown an error')
206-
} catch (error) {
207-
assert.ok(error.message.includes('Can\'t set both "srcPath" & "content"'))
208-
}
203+
// When both srcPath and content are provided, content is used as preloaded
204+
// file contents (caching optimization) — no error should be thrown.
205+
const result = await processFile(options)
206+
assert.ok(result, 'Should return a result without throwing')
209207
})
210208

211209
test('should handle file with output directory', async () => {

0 commit comments

Comments
 (0)