Commit f50cb38a authored by Savas Vedova's avatar Savas Vedova

Fallback to toString method instead of computing the value

parent 3def11a6
...@@ -7,17 +7,8 @@ export default { ...@@ -7,17 +7,8 @@ export default {
required: true, required: true,
}, },
}, },
computed: {
printValue() {
if (typeof this.value === 'boolean') {
return this.value ? 'true' : 'false';
}
return this.value;
},
},
}; };
</script> </script>
<template> <template>
<span>{{ printValue }}</span> <span>{{ value }}</span>
</template> </template>
...@@ -5,12 +5,12 @@ describe('ee/vulnerabilities/components/generic_report/types/value.vue', () => { ...@@ -5,12 +5,12 @@ describe('ee/vulnerabilities/components/generic_report/types/value.vue', () => {
let wrapper; let wrapper;
describe.each` describe.each`
field type | value | printValue field type | value
${'string'} | ${'some string'} | ${'some string'} ${'string'} | ${'some string'}
${'number'} | ${8} | ${'8'} ${'number'} | ${8}
${'boolean'} | ${true} | ${'true'} ${'boolean'} | ${true}
${'boolean'} | ${false} | ${'false'} ${'boolean'} | ${false}
`('with value of type "$fieldType"', ({ fieldType, value, printValue }) => { `('with value of type "$fieldType"', ({ fieldType, value }) => {
const createWrapper = () => { const createWrapper = () => {
return shallowMount(Text, { return shallowMount(Text, {
propsData: { propsData: {
...@@ -29,8 +29,8 @@ describe('ee/vulnerabilities/components/generic_report/types/value.vue', () => { ...@@ -29,8 +29,8 @@ describe('ee/vulnerabilities/components/generic_report/types/value.vue', () => {
wrapper.destroy(); wrapper.destroy();
}); });
it(`renders "${printValue}"`, () => { it(`renders ${fieldType} type`, () => {
expect(wrapper.text()).toBe(printValue); expect(wrapper.text()).toBe(value.toString());
}); });
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment