2019-04-25 23:24:24 +08:00
|
|
|
/* eslint-disable max-classes-per-file */
|
2020-01-31 15:58:37 +08:00
|
|
|
import * as fs from 'fs'
|
2019-03-15 11:42:41 +08:00
|
|
|
import 'jest-extended'
|
2020-01-23 09:51:50 +08:00
|
|
|
import '@testing-library/jest-dom'
|
2020-01-31 15:58:37 +08:00
|
|
|
import yaml from 'js-yaml'
|
2018-07-27 16:54:36 +08:00
|
|
|
|
2018-07-27 18:54:39 +08:00
|
|
|
window.blessing = {
|
2019-03-15 11:42:41 +08:00
|
|
|
base_url: '',
|
2020-03-28 18:25:12 +08:00
|
|
|
locale: 'en',
|
2019-03-15 11:42:41 +08:00
|
|
|
site_name: 'Blessing Skin',
|
|
|
|
version: '4.0.0',
|
2019-04-19 19:32:15 +08:00
|
|
|
extra: {},
|
2020-01-31 15:58:37 +08:00
|
|
|
i18n: yaml.load(fs.readFileSync('resources/lang/en/front-end.yml', 'utf8')),
|
2019-03-15 11:42:41 +08:00
|
|
|
}
|
2018-07-27 18:54:39 +08:00
|
|
|
|
2019-11-26 11:44:44 +08:00
|
|
|
class Headers extends Map {
|
2019-11-26 11:49:10 +08:00
|
|
|
constructor(headers: object = {}) {
|
2019-11-26 11:44:44 +08:00
|
|
|
// @ts-ignore
|
2019-03-17 21:09:46 +08:00
|
|
|
super(Object.entries(headers))
|
|
|
|
}
|
|
|
|
}
|
2019-11-26 11:44:44 +08:00
|
|
|
class Request {
|
|
|
|
public url: string
|
2019-03-17 21:09:46 +08:00
|
|
|
|
2019-11-26 11:44:44 +08:00
|
|
|
public headers: Headers
|
|
|
|
|
|
|
|
constructor(url: string, init: RequestInit) {
|
2019-04-25 23:24:24 +08:00
|
|
|
this.url = url
|
|
|
|
Object.assign(this, init)
|
2019-11-26 11:44:44 +08:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
|
|
this.headers = new Headers(Object.entries(init.headers || {}))
|
2019-04-25 23:24:24 +08:00
|
|
|
}
|
|
|
|
}
|
2019-11-26 11:44:44 +08:00
|
|
|
Object.assign(window, { Headers, Request })
|
2019-04-25 23:24:24 +08:00
|
|
|
|
2019-03-15 11:42:41 +08:00
|
|
|
const noop = () => undefined
|
2019-11-26 11:44:44 +08:00
|
|
|
Object.assign(console, {
|
|
|
|
log: noop,
|
|
|
|
info: noop,
|
|
|
|
warn: noop,
|
|
|
|
error: noop,
|
|
|
|
})
|