blessing-skin-server/resources/assets/tests/views/admin/Customization.test.ts
2019-03-18 15:00:18 +08:00

27 lines
840 B
TypeScript

import Vue from 'vue'
import { mount } from '@vue/test-utils'
import Customization from '@/views/admin/Customization.vue'
window.blessing.extra = { currentSkin: 'skin-blue' }
test('preview color', () => {
document.body.classList.add('skin-blue')
const wrapper = mount(Customization)
wrapper.findAll('a').at(2)
.trigger('click')
expect(document.body.classList.contains('skin-blue')).toBeFalse()
expect(document.body.classList.contains('skin-yellow')).toBeTrue()
})
test('submit color', () => {
Vue.prototype.$http.post.mockResolvedValue({ errno: 0, msg: '' })
const wrapper = mount(Customization)
wrapper.findAll('a').at(4)
.trigger('click')
wrapper.find('button').trigger('click')
expect(Vue.prototype.$http.post).toBeCalledWith(
'/admin/customize?action=color',
{ color_scheme: 'skin-green' }
)
})