#49 feat: gráficos de provenance (proveedores-organizaciones y territorios) en el resumen público
This commit is contained in:
@@ -6,8 +6,15 @@ import OrderCustomer from '@/components/order/OrderCustomer.vue'
|
||||
import OrderLines from '@/components/order/OrderLines.vue'
|
||||
import OrderTotal from '@/components/order/OrderTotal.vue'
|
||||
import OrderPayment from '@/components/order/OrderPayment.vue'
|
||||
import ProvenanceSection from '@/components/provenance/ProvenanceSection.vue'
|
||||
import vuetify from '@/plugins/vuetify'
|
||||
|
||||
const ProvenanceSectionStub = {
|
||||
name: 'ProvenanceSection',
|
||||
props: ['provenance'],
|
||||
template: '<div data-test="provenance-section" />',
|
||||
}
|
||||
|
||||
const saleData = {
|
||||
id: 5,
|
||||
code: 'abc123',
|
||||
@@ -33,7 +40,10 @@ const catalogData = {
|
||||
function mountSummary (props) {
|
||||
return mount(PublicOrderSummary, {
|
||||
props,
|
||||
global: { plugins: [vuetify] },
|
||||
global: {
|
||||
plugins: [vuetify],
|
||||
stubs: { ProvenanceSection: ProvenanceSectionStub },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -87,4 +97,28 @@ describe('PublicOrderSummary', () => {
|
||||
expect(wrapper.text()).not.toContain('Camilo')
|
||||
expect(wrapper.findComponent(OrderLines).exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('no renderiza la sección de provenance cuando la respuesta no la incluye', () => {
|
||||
const wrapper = mountSummary({ purchase: saleData })
|
||||
|
||||
expect(wrapper.findComponent(ProvenanceSection).exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('renderiza la sección de provenance cuando el resumen la incluye', () => {
|
||||
const withProvenance = {
|
||||
...saleData,
|
||||
product_provenance: [
|
||||
{
|
||||
product: { id: 10, name: 'Panela' },
|
||||
suppliers: [{ supplier: { id: 5, name: 'La Mesa' }, organization: { id: 3, name: 'Red' }, municipality: { id: 7, name: 'La Mesa' }, department: { id: 2, name: 'Cundinamarca' }, country: { id: 1, name: 'Colombia', code: 'CO' } }],
|
||||
},
|
||||
],
|
||||
}
|
||||
const wrapper = mountSummary({ purchase: withProvenance })
|
||||
|
||||
expect(wrapper.findComponent(ProvenanceSection).exists()).toBe(true)
|
||||
expect(wrapper.findComponent(ProvenanceSection).props('provenance')).toEqual(
|
||||
withProvenance.product_provenance
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user