Test cases for #61

This commit is contained in:
yushijinhun 2019-05-18 20:40:28 +08:00
parent 1269fdaa82
commit b4ab63907c
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4

View File

@ -38,7 +38,7 @@ test('button for adding to closet should be disabled if not auth', () => {
expect(wrapper.find(Button).attributes('disabled')).toBe('disabled')
})
test('button for adding to closet should be disabled if auth', () => {
test('button for adding to closet should be enabled if auth', () => {
Vue.prototype.$http.get.mockResolvedValue({ data: {} })
Object.assign(window.blessing.extra, { inCloset: true, currentUid: 1 })
const wrapper = mount(Show, {
@ -132,6 +132,28 @@ test('operation panel should not be rendered if not auth', () => {
expect(wrapper.find('.box-warning').exists()).toBeFalse()
})
test('operation panel should not be rendered if not privileged', () => {
Object.assign(window.blessing.extra, { currentUid: 2 })
Vue.prototype.$http.get.mockResolvedValue({ data: { uploader: 1 } })
const wrapper = mount(Show, {
mocks: {
$route: ['/skinlib/show/1', '1'],
},
})
expect(wrapper.find('.box-warning').exists()).toBeFalse()
})
test('operation panel should be rendered if privileged', () => {
Object.assign(window.blessing.extra, { currentUid: 1 })
Vue.prototype.$http.get.mockResolvedValue({ data: { uploader: 1 } })
const wrapper = mount(Show, {
mocks: {
$route: ['/skinlib/show/1', '1'],
},
})
expect(wrapper.find('.box-warning').exists()).toBeTrue()
})
test('download texture', async () => {
Object.assign(window.blessing.extra, { currentUid: 1 })
Vue.prototype.$http.get.mockResolvedValue({ data: { tid: 1, name: 'abc' } })