blessing-skin-server/resources/assets/tests/setup.js

37 lines
786 B
JavaScript
Raw Normal View History

2019-03-15 16:50:16 +08:00
/* eslint-disable import/no-extraneous-dependencies */
2019-03-15 11:42:41 +08:00
import 'jest-extended'
import Vue from 'vue'
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: '',
site_name: 'Blessing Skin',
version: '4.0.0',
}
2018-07-27 18:54:39 +08:00
2019-03-17 21:09:46 +08:00
window.Headers = class extends Map {
constructor(headers = {}) {
super(Object.entries(headers))
}
}
2019-03-15 11:42:41 +08:00
const noop = () => undefined
// eslint-disable-next-line no-console
Object.keys(console).forEach(method => (console[method] = noop))
2018-07-31 10:18:14 +08:00
2019-03-15 11:42:41 +08:00
Vue.prototype.$t = key => key
2018-07-27 16:54:36 +08:00
Vue.directive('t', (el, { value }) => {
2019-03-15 11:42:41 +08:00
if (typeof value === 'string') {
el.innerHTML = value
} else if (typeof value === 'object') {
el.innerHTML = value.path
} else {
throw new Error('[i18n] Invalid arguments in `v-t` directive.')
}
})
2018-08-06 12:14:20 +08:00
Vue.prototype.$http = {
2019-03-15 11:42:41 +08:00
get: jest.fn(),
post: jest.fn(),
}