remove use of global in test
This commit is contained in:
parent
bfa6c00e45
commit
74522103a2
|
@ -11,7 +11,7 @@ function displayEvents(data, list) {
|
|||
for (let i = 0; i < eventsCount; i++) {
|
||||
const li = document.createElement('li')
|
||||
|
||||
const a = createAnchorElement({ text: events[i].title, url: events[i].url })
|
||||
const a = createAnchorElement({ document, text: events[i].title, url: events[i].url })
|
||||
li.appendChild(a)
|
||||
|
||||
const br = document.createElement('br')
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
import test from 'ava'
|
||||
import { JSDOM } from 'jsdom'
|
||||
|
||||
import * as HtmlCreator from './html-creator'
|
||||
import { createAnchorElement } from './html-creator'
|
||||
|
||||
let document
|
||||
|
||||
test.beforeEach(() => {
|
||||
global.document = new JSDOM().window.document
|
||||
document = new JSDOM().window.document
|
||||
})
|
||||
|
||||
test('#createAnchorElement usual parameters', t => {
|
||||
const a = HtmlCreator.createAnchorElement({ text: 'a', url: 'b' })
|
||||
const a = createAnchorElement({ document, text: 'a', url: 'b' })
|
||||
t.is(a.tagName, 'A')
|
||||
t.is(a.innerHTML, 'a')
|
||||
t.is(a.getAttribute('href'), 'b')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export function createAnchorElement({ text, url }) {
|
||||
export function createAnchorElement({ document, text, url }) {
|
||||
const a = document.createElement('a')
|
||||
a.setAttribute('href', url)
|
||||
a.setAttribute('target', '_blank')
|
||||
|
|
Loading…
Reference in New Issue