|
| 1 | +import type { VueWrapper } from '@vue/test-utils'; |
| 2 | + |
| 3 | +import { mount } from '@vue/test-utils'; |
| 4 | + |
| 5 | +import { appInformationMock, serverInformationMock } from '@/test/fixtures'; |
| 6 | + |
| 7 | +import AboutApp from './AboutApp.vue'; |
| 8 | + |
| 9 | +function factory(props = {}) { |
| 10 | + return mount(AboutApp, { |
| 11 | + props: { |
| 12 | + appInformation: appInformationMock, |
| 13 | + serverInformation: serverInformationMock, |
| 14 | + ...props, |
| 15 | + }, |
| 16 | + }); |
| 17 | +} |
| 18 | + |
| 19 | +describe('AboutApp', () => { |
| 20 | + let wrapper: VueWrapper; |
| 21 | + |
| 22 | + beforeEach(() => { |
| 23 | + wrapper = factory(); |
| 24 | + }); |
| 25 | + |
| 26 | + it('matches the snapshot', () => { |
| 27 | + expect(wrapper.html()).toMatchSnapshot(); |
| 28 | + }); |
| 29 | + |
| 30 | + describe('when the serverInformation prop name key is defined', () => { |
| 31 | + it('shows the server name element', () => { |
| 32 | + expect(wrapper.find({ ref: 'name' }).exists()).toBe(true); |
| 33 | + }); |
| 34 | + }); |
| 35 | + |
| 36 | + describe('when the serverInformation prop name key is not defined', () => { |
| 37 | + beforeEach(() => { |
| 38 | + wrapper = factory({ |
| 39 | + serverInformation: { |
| 40 | + ...serverInformationMock, |
| 41 | + name: undefined, |
| 42 | + }, |
| 43 | + }); |
| 44 | + }); |
| 45 | + |
| 46 | + it('does not show the server name element', () => { |
| 47 | + expect(wrapper.find({ ref: 'name' }).exists()).toBe(false); |
| 48 | + }); |
| 49 | + }); |
| 50 | + |
| 51 | + describe('when the serverInformation prop version key is defined', () => { |
| 52 | + it('shows the server version element', () => { |
| 53 | + expect(wrapper.find({ ref: 'version' }).exists()).toBe(true); |
| 54 | + }); |
| 55 | + }); |
| 56 | + |
| 57 | + describe('when the serverInformation prop version key is not defined', () => { |
| 58 | + beforeEach(() => { |
| 59 | + wrapper = factory({ |
| 60 | + serverInformation: { |
| 61 | + ...serverInformationMock, |
| 62 | + version: undefined, |
| 63 | + }, |
| 64 | + }); |
| 65 | + }); |
| 66 | + |
| 67 | + it('does not show the server version element', () => { |
| 68 | + expect(wrapper.find({ ref: 'version' }).exists()).toBe(false); |
| 69 | + }); |
| 70 | + }); |
| 71 | + |
| 72 | + describe('when the serverInformation prop openSubsonic key is defined', () => { |
| 73 | + it('shows the openSubsonic element', () => { |
| 74 | + expect(wrapper.find({ ref: 'openSubsonic' }).exists()).toBe(true); |
| 75 | + }); |
| 76 | + }); |
| 77 | + |
| 78 | + describe('when the serverInformation prop openSubsonic key is not defined', () => { |
| 79 | + beforeEach(() => { |
| 80 | + wrapper = factory({ |
| 81 | + serverInformation: { |
| 82 | + ...serverInformationMock, |
| 83 | + openSubsonic: undefined, |
| 84 | + }, |
| 85 | + }); |
| 86 | + }); |
| 87 | + |
| 88 | + it('does not show the openSubsonic element', () => { |
| 89 | + expect(wrapper.find({ ref: 'openSubsonic' }).exists()).toBe(false); |
| 90 | + }); |
| 91 | + }); |
| 92 | +}); |
0 commit comments