23 lines
687 B
TypeScript
23 lines
687 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { bodyImageIds } from '../bodyImageIds'
|
|
|
|
describe('bodyImageIds', () => {
|
|
it('lists the ids of the images that carry data-image-id', () => {
|
|
const body =
|
|
'<p>a</p><img src="/a.jpg" alt="" data-image-id="1"><p>b</p><img data-image-id="4" src="/b.svg">'
|
|
|
|
expect(bodyImageIds(body)).toEqual([1, 4])
|
|
})
|
|
|
|
it('ignores images without an id and non numeric ids', () => {
|
|
const body =
|
|
'<img src="/a.jpg"><img src="/b.jpg" data-image-id="abc"><img data-image-id="">'
|
|
|
|
expect(bodyImageIds(body)).toEqual([])
|
|
})
|
|
|
|
it('returns nothing for a body without images', () => {
|
|
expect(bodyImageIds('<p>Hello</p>')).toEqual([])
|
|
})
|
|
})
|