Added category tags tests.

This commit is contained in:
Marvin Rabe 2018-05-07 18:29:05 +02:00
parent 68353fb874
commit 6ee21dcfa9

View file

@ -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: '<p>This is a slot.</p>',
},
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.');
});
});