2022-09-06 12:03:37 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
2022-12-08 11:04:25 +00:00
|
|
|
import PrimeVue from 'primevue/config';
|
2022-09-06 12:03:37 +00:00
|
|
|
import DataView from './DataView.vue';
|
|
|
|
|
|
|
|
describe('DataView.vue', () => {
|
2022-09-14 11:26:01 +00:00
|
|
|
it('should exist', () => {
|
2022-09-06 12:03:37 +00:00
|
|
|
const wrapper = mount(DataView, {
|
2022-12-08 11:04:25 +00:00
|
|
|
global: {
|
|
|
|
plugins: [PrimeVue]
|
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
props: {
|
|
|
|
value: [
|
|
|
|
{
|
2022-09-14 11:26:01 +00:00
|
|
|
id: '1000',
|
|
|
|
code: 'f230fh0g3',
|
|
|
|
name: 'Bamboo Watch',
|
|
|
|
description: 'Product Description',
|
|
|
|
image: 'bamboo-watch.jpg',
|
|
|
|
price: 65,
|
|
|
|
category: 'Accessories',
|
|
|
|
quantity: 24,
|
|
|
|
inventoryStatus: 'INSTOCK',
|
|
|
|
rating: 5
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
{
|
2022-09-14 11:26:01 +00:00
|
|
|
id: '1001',
|
|
|
|
code: 'nvklal433',
|
|
|
|
name: 'Black Watch',
|
|
|
|
description: 'Product Description',
|
|
|
|
image: 'black-watch.jpg',
|
|
|
|
price: 72,
|
|
|
|
category: 'Accessories',
|
|
|
|
quantity: 61,
|
|
|
|
inventoryStatus: 'INSTOCK',
|
|
|
|
rating: 4
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
{
|
2022-09-14 11:26:01 +00:00
|
|
|
id: '1002',
|
|
|
|
code: 'zz21cz3c1',
|
|
|
|
name: 'Blue Band',
|
|
|
|
description: 'Product Description',
|
|
|
|
image: 'blue-band.jpg',
|
|
|
|
price: 79,
|
|
|
|
category: 'Fitness',
|
|
|
|
quantity: 2,
|
|
|
|
inventoryStatus: 'LOWSTOCK',
|
|
|
|
rating: 3
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
layout: 'grid',
|
2022-09-14 11:26:01 +00:00
|
|
|
paginator: true,
|
2022-09-06 12:03:37 +00:00
|
|
|
rows: 3
|
|
|
|
},
|
|
|
|
slots: {
|
|
|
|
grid: `
|
|
|
|
<template #grid="slotProps">
|
2024-05-24 06:25:19 +00:00
|
|
|
<div class="grid">
|
2023-11-21 14:07:38 +00:00
|
|
|
<div v-for="(item, index) in slotProps.items" :key="index" class="col-12 md:col-4">
|
|
|
|
<div class="product-grid-item card">
|
|
|
|
<div class="product-grid-item-top">
|
|
|
|
<div>
|
|
|
|
<i class="pi pi-tag product-category-icon"></i>
|
|
|
|
<span class="product-category">{{item.category}}</span>
|
|
|
|
</div>
|
|
|
|
<span :class="'product-badge status-'+item.inventoryStatus.toLowerCase()">{{item.inventoryStatus}}</span>
|
|
|
|
</div>
|
|
|
|
<div class="product-grid-item-content">
|
|
|
|
<img :src="'images/product/' + item.image" :alt="item.name"/>
|
|
|
|
<div class="product-name">{{item.name}}</div>
|
|
|
|
<div class="product-description">{{item.description}}</div>
|
|
|
|
</div>
|
|
|
|
<div class="product-grid-item-bottom">
|
|
|
|
<span class="product-price">\${{item.price}}</span>
|
2022-09-06 12:03:37 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
`
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper.find('.p-dataview.p-component').exists()).toBe(true);
|
|
|
|
expect(wrapper.find('.p-dataview-grid').exists()).toBe(true);
|
|
|
|
expect(wrapper.findAll('.product-grid-item').length).toBe(3);
|
|
|
|
expect(wrapper.find('.p-paginator.p-component').exists()).toBe(true);
|
|
|
|
});
|
2022-09-14 11:26:01 +00:00
|
|
|
});
|