42 lines
2.2 KiB
JavaScript
42 lines
2.2 KiB
JavaScript
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
import { JSDOM } from 'jsdom';
|
|
|
|
beforeAll(() => {
|
|
const dom = new JSDOM('<!doctype html><html><body><div id="main"></div></body></html>', { url: 'http://localhost/' });
|
|
global.window = dom.window; global.document = dom.window.document;
|
|
global.Node = dom.window.Node; global.location = dom.window.location;
|
|
});
|
|
afterAll(() => { delete global.window; delete global.document; delete global.Node; delete global.location; });
|
|
|
|
describe('embedView + wrappers', () => {
|
|
it('mounts an iframe with the given src + matching Open link', async () => {
|
|
const { embedView } = await import('../../public/views/embed.js');
|
|
const main = document.getElementById('main');
|
|
await embedView({ title: 'Timelapse', sub: 'x', src: 'https://timelapse.hynesy.com/', allow: 'fullscreen' })(main);
|
|
const frame = main.querySelector('iframe.term-frame');
|
|
expect(frame.getAttribute('src')).toBe('https://timelapse.hynesy.com/');
|
|
expect(frame.getAttribute('allow')).toBe('fullscreen');
|
|
expect(main.querySelector('a.ghost').getAttribute('href')).toBe('https://timelapse.hynesy.com/');
|
|
expect(main.querySelector('.term-title').textContent).toContain('Timelapse');
|
|
});
|
|
|
|
it('timelapse wrapper points at timelapse.hynesy.com', async () => {
|
|
const main = document.getElementById('main');
|
|
await (await import('../../public/views/timelapse.js')).render(main);
|
|
expect(main.querySelector('iframe.term-frame').getAttribute('src')).toBe('https://timelapse.hynesy.com/');
|
|
});
|
|
|
|
it('aiusage wrapper points at aiusage.hynesy.com', async () => {
|
|
const main = document.getElementById('main');
|
|
await (await import('../../public/views/aiusage.js')).render(main);
|
|
expect(main.querySelector('iframe.term-frame').getAttribute('src')).toBe('https://aiusage.hynesy.com/');
|
|
});
|
|
|
|
it('omits the allow attribute when not provided', async () => {
|
|
const { embedView } = await import('../../public/views/embed.js');
|
|
const main = document.getElementById('main');
|
|
await embedView({ title: 'AI Usage', src: 'https://aiusage.hynesy.com/' })(main);
|
|
expect(main.querySelector('iframe.term-frame').hasAttribute('allow')).toBe(false);
|
|
});
|
|
});
|