Skip to content

Commit

Permalink
Clean test unit ouput (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexEbenrode authored Oct 3, 2024
1 parent 2b5f51c commit 8755274
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/components/VAvatarSettings/VAvatarSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('VAvatarSettings', () => {
],
stubs: {
VCard: false,
AvatarCropper: true,
},
},
});
Expand Down
15 changes: 11 additions & 4 deletions src/components/VHeader/VHeader.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mount, VueWrapper } from '@vue/test-utils';
import { mount, RouterLinkStub, VueWrapper } from '@vue/test-utils';
import { faker } from '@faker-js/faker';
import VHeader from './VHeader.vue';
import { useRoute } from 'vue-router';
Expand All @@ -9,7 +9,14 @@ describe('VHeader', () => {
let wrapper: VueWrapper<InstanceType<typeof VHeader>>;

const mountComponent = () => {
wrapper = mount(VHeader, { shallow: true });
wrapper = mount(VHeader, {
shallow: true,
global: {
stubs: {
RouterLink: RouterLinkStub,
},
},
});
};

beforeEach(() => {
Expand All @@ -20,12 +27,12 @@ describe('VHeader', () => {
mountComponent();
});

const getLogoWrapper = () => wrapper.find('[data-testid="logo"]');
const getLogoWrapper = () => wrapper.findComponent(RouterLinkStub);
const getProfileMenuWrapper = () => wrapper.find('[data-testid="profile"]');

test('has logo that leads to home page', () => {
expect(getLogoWrapper().exists()).toBe(true);
expect(getLogoWrapper().attributes('to')).toBe('/');
expect(getLogoWrapper().props().to).toBe('/');
});

test('has profile menu if route is private', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/components/VRadioSwitch/VRadioSwitch.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mount } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import { describe, test, expect } from 'vitest';
import VRadioSwitch from './VRadioSwitch.vue';
import { SunFilledIcon, MoonFilledIcon } from 'vue-tabler-icons';
Expand All @@ -10,7 +10,7 @@ describe('VRadioSwitch', () => {
];

test('renders all options', () => {
const wrapper = mount(VRadioSwitch, {
const wrapper = shallowMount(VRadioSwitch, {
props: {
options,
modelValue: 'option1',
Expand All @@ -30,7 +30,7 @@ describe('VRadioSwitch', () => {
});

test('highlights active option', () => {
const wrapper = mount(VRadioSwitch, {
const wrapper = shallowMount(VRadioSwitch, {
props: {
options,
modelValue: 'option2',
Expand All @@ -49,7 +49,7 @@ describe('VRadioSwitch', () => {
});

test('emits update:modelValue event on click', async () => {
const wrapper = mount(VRadioSwitch, {
const wrapper = shallowMount(VRadioSwitch, {
props: {
options,
modelValue: 'option1',
Expand Down
1 change: 0 additions & 1 deletion src/stores/homework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const useHomework = defineStore('homework', {
) {
(answers || this.answers).forEach((item) => {
if (item.slug === answer.slug) {
console.log(answer, item);
return Object.assign(item, answer);
}

Expand Down

0 comments on commit 8755274

Please sign in to comment.