mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-04 04:59:40 +00:00
Added sidebar section test.
This commit is contained in:
parent
68526c07ae
commit
68353fb874
2 changed files with 58 additions and 0 deletions
54
test/client/unit/specs/components/sidebarSection.js
Normal file
54
test/client/unit/specs/components/sidebarSection.js
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
import {shallow} from '@vue/test-utils';
|
||||||
|
|
||||||
|
import SidebarSection from 'client/components/sidebarSection.vue';
|
||||||
|
|
||||||
|
describe('Sidebar Section', () => {
|
||||||
|
let wrapper;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
wrapper = shallow(SidebarSection, {
|
||||||
|
propsData: {
|
||||||
|
title: 'Hello World',
|
||||||
|
},
|
||||||
|
slots: {
|
||||||
|
default: '<p>This is a test.</p>',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays title', () => {
|
||||||
|
expect(wrapper.find('h3').text()).to.eq('Hello World');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays contents', () => {
|
||||||
|
expect(wrapper.find('.section-body').find('p').text()).to.eq('This is a test.');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays tooltip icon', () => {
|
||||||
|
expect(wrapper.contains('.section-info')).to.eq(false);
|
||||||
|
wrapper.setProps({tooltip: 'This is a test'});
|
||||||
|
expect(wrapper.contains('.section-info')).to.eq(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('hides contents', () => {
|
||||||
|
expect(wrapper.find('.section-body').element.style.display).to.not.eq('none');
|
||||||
|
wrapper.find('.section-toggle').trigger('click');
|
||||||
|
expect(wrapper.find('.section-body').element.style.display).to.eq('none');
|
||||||
|
wrapper.find('.section-toggle').trigger('click');
|
||||||
|
expect(wrapper.find('.section-body').element.style.display).to.not.eq('none');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can hide contents by default', () => {
|
||||||
|
wrapper = shallow(SidebarSection, {
|
||||||
|
propsData: {
|
||||||
|
title: 'Hello World',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
slots: {
|
||||||
|
default: '<p>This is a test.</p>',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.find('.section-body').element.style.display).to.eq('none');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -58,6 +58,7 @@
|
||||||
import upIcon from 'assets/svg/up.svg';
|
import upIcon from 'assets/svg/up.svg';
|
||||||
import downIcon from 'assets/svg/down.svg';
|
import downIcon from 'assets/svg/down.svg';
|
||||||
import informationIcon from 'assets/svg/information.svg';
|
import informationIcon from 'assets/svg/information.svg';
|
||||||
|
import bTooltip from 'bootstrap-vue/es/components/tooltip/tooltip';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -71,6 +72,9 @@
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
components: {
|
||||||
|
bTooltip,
|
||||||
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
tooltipId: uuid(),
|
tooltipId: uuid(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue