Skip to content

Commit

Permalink
chore: bump types/node from 12.12.31 -> 18.7.6
Browse files Browse the repository at this point in the history
  • Loading branch information
starpit committed Sep 8, 2022
1 parent e254160 commit 2abee22
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 70 deletions.
62 changes: 7 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@types/mkdirp": "1.0.2",
"@types/mocha": "9.1.1",
"@types/needle": "2.5.3",
"@types/node": "12.12.31",
"@types/node": "18.7.16",
"@types/pluralize": "0.0.29",
"@types/react": "17.0.43",
"@types/react-dom": "17.0.14",
Expand Down
28 changes: 14 additions & 14 deletions packages/core/src/util/mimic-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export default function () {
global.window = {
navigator: {
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:74.0) Gecko/20100101 Firefox/74.0'
}
}
} as any as Window['navigator']
} as any as Window & typeof globalThis
try {
global.localStorage = Store()
global.sessionStorage = Store()
global.localStorage = Store() as any as Storage
global.sessionStorage = Store() as any as Storage
debug('successfully initialized persistent localStorage')
} catch (err) {
debug('error initializing persistent localStorage', err)
Expand All @@ -48,48 +48,48 @@ export default function () {
return v
},
getItem: (k: string) => _localStorage[k] || null
}
} as any as Storage
global.sessionStorage = {
setItem: (k: string, v: string) => {
_sessionStorage[k] = v
return v
},
getItem: (k: string) => _sessionStorage[k] || null
}
} as any as Storage
} finally {
global.window.localStorage = localStorage
global.window.sessionStorage = sessionStorage
}

window.addEventListener = () => true

const dom0 = (): ElementMimic => {
return new ElementMimic()
const dom0 = (): ElementMimic & HTMLElement => {
return new ElementMimic() as ElementMimic & HTMLElement
}

global.document = {
body: dom0(),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
getElementById: (id: string) => dom0(),
createElement: (tag: string) => {
createElement: <T>(tag: string) => {
const element = dom0()
element.nodeType = tag
;(element as any as { nodeType: string }).nodeType = tag
if (tag === 'table') {
element.rows = []
;(element as any as { rows: any[] }).rows = []
}
return element
return element as any as T
},
addEventListener: () => true,
createTextNode: (text: string) => {
const element = dom0()
element.innerText = text
return element
return element as any as Text
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
querySelector: (selector: string) => {
return dom0()
}
}
} as any as Document

debug('mimicDom done')
}

0 comments on commit 2abee22

Please # to comment.