#6992 add URL params #273
|
@ -196,7 +196,7 @@ export function useArrayData(key, userOptions) {
|
|||
for (const param in query) params.append(param, query[param]);
|
||||
|
||||
url.hash = currentRoute + '?' + params.toString();
|
||||
jsegarra marked this conversation as resolved
Outdated
|
||||
window.history.pushState({}, '', url);
|
||||
window.history.pushState({}, '', url.hash);
|
||||
}
|
||||
|
||||
const totalRows = computed(() => (store.data && store.data.length) || 0);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
import { describe, expect, it, beforeAll } from 'vitest';
|
||||
import { axios } from 'app/test/vitest/helper';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
|
||||
describe('useArrayData', () => {
|
||||
let arrayData;
|
||||
beforeAll(() => {
|
||||
axios.get.mockResolvedValue({ data: [] });
|
||||
arrayData = useArrayData('InvoiceIn', { url: 'invoice-in/list' });
|
||||
Object.defineProperty(window.location, 'href', {
|
||||
writable: true,
|
||||
value: 'localhost:9000/invoice-in/list',
|
||||
});
|
||||
window.history.pushState = (data, title, url) => (window.location.href = url);
|
||||
jorgep marked this conversation as resolved
Outdated
jorgep
commented
No sé porque vitest no reconoce esta función, tampoco reconoce la clase URL, he tenido que simular el comportamiento. No sé porque vitest no reconoce esta función, tampoco reconoce la clase URL, he tenido que simular el comportamiento.
jsegarra
commented
hablas de la función de pushState? hablas de la función de pushState?
jorgep
commented
sí sí
jsegarra
commented
Poner comentario indicando que se está mockeando el método para usar dentro de useArrayData e igual para class URL Poner comentario indicando que se está mockeando el método para usar dentro de useArrayData e igual para class URL
|
||||
global.URL = class URL {
|
||||
constructor(url) {
|
||||
this.hash = url.split('localhost:9000/')[1];
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('should add the params to the url', async () => {
|
||||
arrayData.store.userParams = { supplierFk: 2 };
|
||||
arrayData.updateStateParams();
|
||||
expect(window.location.href).contain('params=%7B%22supplierFk%22%3A2%7D');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
porque no usas currentHash?
Idem para la siguiente linea
Porque currentRoute es solo la ruta . Ej. currentRoute = #/claim/list y currentHash = #/claim/list?order=priority+ASC%2Ccreated+DESC&limit=10¶ms=%7B%22clientName%22%3A%22br%22%7D . CurrentHash es la ruta con los parámetros actuales.