ray-template/__test__/components/iframe-loading.spec.ts

19 lines
486 B
TypeScript

import { RIframe } from '@/components/RIframe'
import { mount } from '@vue/test-utils'
describe('RIframe loading strategy', () => {
it.each([
[true, 'lazy'],
[false, 'eager'],
['eager', 'eager'],
] as const)('sets loading=%s to %s', (lazy, expected) => {
const wrapper = mount(RIframe, { props: { lazy, src: '/embed.html' } })
try {
expect(wrapper.get('iframe').attributes('loading')).toBe(expected)
} finally {
wrapper.unmount()
}
})
})