From fc549cae979fbb078ab460ed82fda60c2db121ef Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 12 Mar 2025 14:18:10 +0100 Subject: [PATCH] test: refs #6994 create test VnLogValue front --- .../common/__tests__/VnLogValue.spec.js | 26 +++++++++++++++++++ src/stores/useDescriptorStore.js | 3 +-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/components/common/__tests__/VnLogValue.spec.js diff --git a/src/components/common/__tests__/VnLogValue.spec.js b/src/components/common/__tests__/VnLogValue.spec.js new file mode 100644 index 000000000..c23743a02 --- /dev/null +++ b/src/components/common/__tests__/VnLogValue.spec.js @@ -0,0 +1,26 @@ +import { describe, it, expect } from 'vitest'; +import VnLogValue from 'src/components/common/VnLogValue.vue'; +import { createWrapper } from 'app/test/vitest/helper'; + +const buildComponent = (props) => { + return createWrapper(VnLogValue, { + props, + global: {}, + }).wrapper; +}; + +describe('VnLogValue', () => { + const id = 1; + it('renders without descriptor', async () => { + expect(getIcon('inventFk').exists()).toBe(false); + }); + + it('renders with descriptor', async () => { + expect(getIcon('claimFk').text()).toBe('launch'); + }); + + function getIcon(name) { + const wrapper = buildComponent({ value: { val: id }, name }); + return wrapper.find('.q-icon'); + } +}); diff --git a/src/stores/useDescriptorStore.js b/src/stores/useDescriptorStore.js index 150db7fbd..89189f32e 100644 --- a/src/stores/useDescriptorStore.js +++ b/src/stores/useDescriptorStore.js @@ -2,9 +2,8 @@ import { defineAsyncComponent } from 'vue'; import { defineStore } from 'pinia'; import { useStateStore } from 'stores/useStateStore'; -const { descriptors, setDescriptors } = useStateStore(); - export const useDescriptorStore = defineStore('descriptorStore', () => { + const { descriptors, setDescriptors } = useStateStore(); function get() { if (Object.keys(descriptors).length) return descriptors;