Hide setAsAvatar if texture is cape

This commit is contained in:
Pig Fang 2019-03-16 23:47:56 +08:00
parent afb65615b0
commit 70c9226bf8
2 changed files with 8 additions and 1 deletions
resources/assets
src/components/user
tests/components/user

View File

@ -26,7 +26,7 @@
<ul class="dropup dropdown-menu" aria-labelledby="more-button">
<li><a v-t="'user.renameItem'" @click="rename" /></li>
<li><a v-t="'user.removeItem'" @click="remove" /></li>
<li><a v-t="'user.setAsAvatar'" @click="setAsAvatar" /></li>
<li><a v-if="type !== 'cape'" v-t="'user.setAsAvatar'" @click="setAsAvatar" /></li>
</ul>
</div>
</div>

View File

@ -87,6 +87,7 @@ test('remove texture', async () => {
expect(wrapper.emitted()['item-removed']).toBeTruthy()
expect(Vue.prototype.$http.post).toBeCalledWith('/user/closet/remove', { tid: 1 })
})
test('set as avatar', async () => {
Vue.prototype.$http.post
.mockResolvedValueOnce({ errno: 0 })
@ -121,3 +122,9 @@ test('set as avatar', async () => {
expect(Vue.prototype.$http.post).toBeCalledWith('/user/profile/avatar', { tid: 1 })
expect(window.$).toBeCalledWith('[alt="User Image"]')
})
test('no avatar option if texture is cape', () => {
const wrapper = mount(ClosetItem, { propsData: factory({ type: 'cape' }) })
const button = wrapper.findAll('.dropdown-menu > li').at(2)
expect(button.isEmpty()).toBeTrue()
})