diff --git a/test/client/unit/specs/components/categories/categoryTags.js b/test/client/unit/specs/components/categories/categoryTags.js new file mode 100644 index 0000000000..a0ea2e69b7 --- /dev/null +++ b/test/client/unit/specs/components/categories/categoryTags.js @@ -0,0 +1,65 @@ +import {shallow} from '@vue/test-utils'; + +import CategoryTags from 'client/components/categories/categoryTags.vue'; + +describe('Category Tags', () => { + let wrapper; + + beforeEach(function () { + wrapper = shallow(CategoryTags, { + propsData: { + categories: [], + }, + slots: { + default: '
This is a slot.
', + }, + mocks: { + $t: (string) => string, + }, + }); + }); + + it('displays a category', () => { + wrapper.setProps({ + categories: [ + { + name: 'test', + }, + ], + }); + expect(wrapper.contains('.category-label')).to.eq(true); + expect(wrapper.find('.category-label').text()).to.eq('test'); + }); + + it('displays a habitica official in purple', () => { + wrapper.setProps({ + categories: [ + { + name: 'habitica_official', + }, + ], + }); + expect(wrapper.contains('.category-label-purple')).to.eq(true); + expect(wrapper.find('.category-label').text()).to.eq('habitica_official'); + }); + + it('displays owner label', () => { + wrapper.setProps({ + owner: true, + }); + expect(wrapper.contains('.category-label-blue')).to.eq(true); + expect(wrapper.find('.category-label').text()).to.eq('owned'); + }); + + it('displays member label', () => { + wrapper.setProps({ + member: true, + }); + expect(wrapper.contains('.category-label-green')).to.eq(true); + expect(wrapper.find('.category-label').text()).to.eq('joined'); + }); + + it('displays additional content at the end', () => { + expect(wrapper.find('p').text()).to.eq('This is a slot.'); + }); +}); \ No newline at end of file