feat: #7088 created test for FetchedTags #1162

Merged
provira merged 9 commits from 7088-testFetchedTags into dev 2025-01-09 06:04:16 +00:00
1 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,81 @@
import { describe, expect, it } from 'vitest';
import { createWrapper } from 'app/test/vitest/helper';
import FetchedTags from 'src/components/ui/FetchedTags.vue';
describe('tags computed property', () => {
it('returns an object with the correct keys and values', () => {
const vm = createWrapper(FetchedTags, {

Es mínimo el detalle pero la variable wrapper no se usa en ningún sitio, no tiene mas sentido hacer vm?

Es mínimo el detalle pero la variable wrapper no se usa en ningún sitio, no tiene mas sentido hacer vm?

si, no cambia nada usar wrapper en este caso. ya esta cambiado a vm

si, no cambia nada usar wrapper en este caso. ya esta cambiado a vm
props: {
item: {
tag1: 'JavaScript',
value1: 'Programming Language',
tag2: 'Vue',
value2: 'Framework',
tag3: 'EmptyTag',
},
tag: 'tag',
value: 'value',
columns: 2,
},
}).vm;
expect(vm.tags).toEqual({
JavaScript: 'Programming Language',
Vue: 'Framework',
EmptyTag: '',
});
});
it('returns an empty object if the item prop is an empty object', () => {
const vm = createWrapper(FetchedTags, {
props: {
item: {},
tag: 'tag',
value: 'value',
},
}).vm;
expect(vm.tags).toEqual({});

Es mínimo el detalle pero la variable vm no se usa en ningún sitio, no tiene mas sentido hacer vm.tags?

Es mínimo el detalle pero la variable vm no se usa en ningún sitio, no tiene mas sentido hacer vm.tags?

solucionado

solucionado
});
it('should calculate the correct columnStyle when columns prop is defined', () => {
const vm = createWrapper(FetchedTags, {
props: {
item: {
tag1: 'JavaScript',
value1: 'Programming Language',
tag2: 'Vue',
value2: 'Framework',
tag3: 'EmptyTag',
},
tag: 'tag',
value: 'value',
columns: 2,
},
}).vm;
const expectedStyle = {
'grid-template-columns': 'repeat(2, 1fr)',
'max-width': '8rem',
};
expect(vm.columnStyle).toEqual(expectedStyle);
});
it('should return an empty object for columnStyle when columns prop is not defined', () => {
const vm = createWrapper(FetchedTags, {
props: {
item: {
tag1: 'JavaScript',
value1: 'Programming Language',
tag2: 'Vue',
value2: 'Framework',
tag3: 'EmptyTag',
},
tag: 'tag',
value: 'value',
columns: null,
},
}).vm;
expect(vm.columnStyle).toEqual({});

Es mínimo el detalle pero la variable vm no se usa en ningún sitio, no tiene mas sentido hacer vm.columnStyle?

Es mínimo el detalle pero la variable vm no se usa en ningún sitio, no tiene mas sentido hacer vm.columnStyle?

solucionado

solucionado
});
});