#8113 create arrayDataStore map #979
|
@ -341,7 +341,6 @@ const openTab = (id) =>
|
||||||
:row-click="({ id }) => openTab(id)"
|
:row-click="({ id }) => openTab(id)"
|
||||||
:disable-option="{ card: true }"
|
:disable-option="{ card: true }"
|
||||||
:user-params="{ from, to, scopeDays: 1 }"
|
:user-params="{ from, to, scopeDays: 1 }"
|
||||||
:limit="3"
|
|
||||||
>
|
>
|
||||||
<template #top-left>
|
<template #top-left>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
|
|
@ -4,7 +4,11 @@ import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||||
|
|
||||||
describe('VnPaginate', () => {
|
describe('VnPaginate', () => {
|
||||||
const expectedUrl = '/api/customers';
|
const expectedUrl = '/api/customers';
|
||||||
|
const defaultData = [
|
||||||
|
{ id: 1, name: 'Tony Stark' },
|
||||||
|
{ id: 2, name: 'Jessica Jones' },
|
||||||
|
{ id: 3, name: 'Bruce Wayne' },
|
||||||
|
];
|
||||||
let vm;
|
let vm;
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
const options = {
|
const options = {
|
||||||
|
@ -28,11 +32,7 @@ describe('VnPaginate', () => {
|
||||||
describe('paginate()', () => {
|
describe('paginate()', () => {
|
||||||
it('should call to the paginate() method and set the data on the rows property', async () => {
|
it('should call to the paginate() method and set the data on the rows property', async () => {
|
||||||
vi.spyOn(vm.arrayData, 'loadMore');
|
vi.spyOn(vm.arrayData, 'loadMore');
|
||||||
vm.store.data = [
|
vm.store.data = defaultData;
|
||||||
{ id: 1, name: 'Tony Stark' },
|
|
||||||
{ id: 2, name: 'Jessica Jones' },
|
|
||||||
{ id: 3, name: 'Bruce Wayne' },
|
|
||||||
];
|
|
||||||
|
|
||||||
await vm.paginate();
|
await vm.paginate();
|
||||||
|
|
||||||
|
@ -42,26 +42,25 @@ describe('VnPaginate', () => {
|
||||||
|
|
||||||
it('should call to the paginate() method and then call it again to paginate', async () => {
|
it('should call to the paginate() method and then call it again to paginate', async () => {
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({
|
vi.spyOn(axios, 'get').mockResolvedValue({
|
||||||
data: [
|
data: defaultData,
|
||||||
{ id: 1, name: 'Tony Stark' },
|
|
||||||
{ id: 2, name: 'Jessica Jones' },
|
|
||||||
{ id: 3, name: 'Bruce Wayne' },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
vm.store.hasMoreData = true;
|
vm.store.hasMoreData = true;
|
||||||
await vm.$nextTick();
|
await vm.$nextTick();
|
||||||
|
|
||||||
vm.store.data = [
|
vm.store.data = defaultData;
|
||||||
{ id: 1, name: 'Tony Stark' },
|
|
||||||
{ id: 2, name: 'Jessica Jones' },
|
|
||||||
{ id: 3, name: 'Bruce Wayne' },
|
|
||||||
];
|
|
||||||
|
|
||||||
await vm.paginate();
|
await vm.paginate();
|
||||||
|
|
||||||
expect(vm.store.skip).toEqual(3);
|
expect(vm.store.skip).toEqual(3);
|
||||||
expect(vm.store.data.length).toEqual(6);
|
expect(vm.store.data.length).toEqual(6);
|
||||||
|
|
||||||
|
vi.spyOn(axios, 'get').mockResolvedValue({
|
||||||
|
|||||||
|
data: [
|
||||||
|
{ id: 4, name: 'Peter Parker' },
|
||||||
|
{ id: 5, name: 'Clark Kent' },
|
||||||
|
{ id: 6, name: 'Barry Allen' },
|
||||||
|
],
|
||||||
|
});
|
||||||
await vm.paginate();
|
await vm.paginate();
|
||||||
|
|
||||||
expect(vm.store.skip).toEqual(6);
|
expect(vm.store.skip).toEqual(6);
|
||||||
|
@ -85,11 +84,7 @@ describe('VnPaginate', () => {
|
||||||
|
|
||||||
const index = 1;
|
const index = 1;
|
||||||
const done = vi.fn();
|
const done = vi.fn();
|
||||||
vm.store.data = [
|
vm.store.data = defaultData;
|
||||||
{ id: 1, name: 'Tony Stark' },
|
|
||||||
{ id: 2, name: 'Jessica Jones' },
|
|
||||||
{ id: 3, name: 'Bruce Wayne' },
|
|
||||||
];
|
|
||||||
|
|
||||||
await vm.onLoad(index, done);
|
await vm.onLoad(index, done);
|
||||||
|
|
||||||
|
@ -105,11 +100,7 @@ describe('VnPaginate', () => {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
vm.store.data = [
|
vm.store.data = defaultData;
|
||||||
{ id: 1, name: 'Tony Stark' },
|
|
||||||
{ id: 2, name: 'Jessica Jones' },
|
|
||||||
{ id: 3, name: 'Bruce Wayne' },
|
|
||||||
];
|
|
||||||
|
|
||||||
expect(vm.pagination.page).toEqual(1);
|
expect(vm.pagination.page).toEqual(1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Si son los mismos registros ahora no los va a volver a añadir.