Untitled
unknown
javascript
a year ago
1.4 kB
3
Indexable
Never
export const videoMarkup = (extractedLink) => { const element = document.createElement('iframe'); element.src = `${extractedLink}?enablejsapi=1&rel=0`; element.setAttribute('allow', 'fullscreen'); element.id = 'player'; element.classList.add('media-video'); return element; }; function videoMarkUpTest{ jest.spyOn(document.createElement).mockReturnValue(element = { // src: '', setAttribute: jest.fn(), // id: '', classList: { add: jest.fn(), }, }); const result = videoMarkup('https://google.com'); expect(element.setAttribute).toBeCalledWith('allow', 'fullscreen'); expect(element.classList.add).toBeCalledWith('media-video'); expect(result).toBe(element = { src: 'https://google.com?enablejsapi=1&rel=0', id: 'player', }); } function videoMarkUpTest{ const result = videoMarkup('https://google.com'); expect(element.getAttribute('src')).toBe('https://google.com?enablejsapi=1&rel=0') expect(element.getAttribute('id')).toBe('player') expect(element.getAttribute('allow')).toBe('fullscreen') expect(element.classList.contains('media-video')).toBe(true) } function videoMarkUpTest{ const element = document.createElement('iframe'); element.src = `${extractedLink}?enablejsapi=1&rel=0`; element.setAttribute('allow', 'fullscreen'); element.id = 'player'; element.classList.add('media-video'); const result = videoMarkup('https://google.com'); expect(result).toBe(element); }