forked from verdnatura/salix-front
test: add front test
This commit is contained in:
parent
0897c6c39c
commit
b48cba686e
|
@ -19,9 +19,15 @@ export function useStateQuery() {
|
|||
queries.value.delete(hash);
|
||||
}
|
||||
|
||||
function reset() {
|
||||
queries.value = new Set();
|
||||
}
|
||||
|
||||
return {
|
||||
add,
|
||||
isLoading,
|
||||
remove,
|
||||
queries,
|
||||
reset,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
import { describe, expect, it, beforeEach } from 'vitest';
|
||||
import { useStateQuery } from 'src/composables/useStateQuery';
|
||||
|
||||
describe('useStateQuery', () => {
|
||||
const { add, isLoading, remove, reset, queries } = useStateQuery();
|
||||
beforeEach(() => {
|
||||
reset();
|
||||
expect(queries.value.size).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should add two queries', async () => {
|
||||
expect(queries.value.size).toBeFalsy();
|
||||
const hash = add();
|
||||
expect(queries.value.size).toBeTruthy();
|
||||
expect(queries.value.has(hash)).toBeTruthy();
|
||||
|
||||
add();
|
||||
expect(queries.value.size).toBe(2);
|
||||
});
|
||||
|
||||
it('should add and remove loading state', async () => {
|
||||
expect(isLoading().value).toBeFalsy();
|
||||
const hash = add();
|
||||
expect(isLoading().value).toBeTruthy();
|
||||
remove(hash);
|
||||
expect(isLoading().value).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should add and remove hash', async () => {
|
||||
add();
|
||||
add();
|
||||
add();
|
||||
|
||||
const beforeCount = queries.value.size;
|
||||
const hash = add();
|
||||
expect(queries.value.has(hash)).toBeTruthy();
|
||||
|
||||
remove(hash);
|
||||
expect(queries.value.has(hash)).toBeFalsy();
|
||||
expect(queries.value.size).toBe(beforeCount);
|
||||
});
|
||||
});
|
|
@ -6,6 +6,7 @@ describe('InvoiceInIntrastat', () => {
|
|||
let vm;
|
||||
|
||||
beforeAll(() => {
|
||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: [{}] });
|
||||
vm = createWrapper(InvoiceInIntrastat, {
|
||||
global: {
|
||||
stubs: ['vnPaginate'],
|
||||
|
@ -14,7 +15,6 @@ describe('InvoiceInIntrastat', () => {
|
|||
},
|
||||
},
|
||||
}).vm;
|
||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: [{}] });
|
||||
});
|
||||
|
||||
describe('getTotal()', () => {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { vi, describe, expect, it, beforeAll } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import InvoiceInVat from 'src/pages/InvoiceIn/Card/InvoiceInVat.vue';
|
||||
|
||||
describe('InvoiceInVat', () => {
|
||||
let vm;
|
||||
|
||||
beforeAll(() => {
|
||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: [{}] });
|
||||
vm = createWrapper(InvoiceInVat, {
|
||||
global: {
|
||||
stubs: [],
|
||||
|
|
Loading…
Reference in New Issue