Skip to content

Commit

Permalink
test: add obsidian reference plugin test
Browse files Browse the repository at this point in the history
  • Loading branch information
danpacho committed Dec 29, 2024
1 parent 5041687 commit a52cce4
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { describe, expect, it } from 'vitest'
import { ObsidianReferencePlugin } from '../core'
import { Tester } from './tester'

describe('ObsidianReferencePlugin', () => {
it('should reference obsidian images', async () => {
const plugin = new ObsidianReferencePlugin()
const res = await Tester.pipe({
plugin: {
'build:contents': plugin,
},
})

const imgFile = res.buildFiles.contents.find(
(e) => e.filename === 'img.md'
)
const imgFilename = res.buildFiles.assets.find((e) =>
e.filename.includes('.png')
)
const imgPath__replaced_origin_build_path = imgFilename?.path.replace(
res.buildPath.assets,
''
)

expect(imgFile?.content).toContain(
`<img src="${imgPath__replaced_origin_build_path}" alt="img.png" />`
)
})
})

0 comments on commit a52cce4

Please sign in to comment.