Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Bank } from '@/common/models';
import { mount } from '@vue/test-utils';
import { expect, describe, it, vi, beforeEach } from 'vitest';
import { installQuasar } from '@quasar/quasar-app-extension-testing-unit-vitest';
import Index from '@/views/investment/Index.vue';
import { Product } from '@/common/models';
import { getProducts } from '@/common/api/api';
/*
* Init and Install Quasar component as plugin test context
*/
installQuasar()
/*
* Reset All mocking data for fresh context
*/
beforeEach(() => { vi.restoreAllMocks() })
const userRoles = () => { }; // Only for mocking, to fix error not found dataUser
describe('Test case investment/Index.Vue', () => {
it('Index.vue should exists', () => {
expect(Index).toBeDefined();
})
it('Index.vue should be mounted and success', () => {
const wrapper = mount(Index,{
global:{
mocks:{
userRoles: userRoles()
}
}
});
expect(wrapper).toBeTruthy()
})
it('Index.vue should be mounted and render some text', () => {
const wrapper = mount(Index,{
global:{
mocks:{
userRoles: userRoles()
}
}
});
expect(wrapper.text()).toContain('Mutual Fund')
})
it('Receive some data and render it', async () => {
const data: Product = {
id: -1,
code: "DEMO-01",
name: "Maleo Private Equity",
logo: {
kind: "WEBP",
filename: "Maleo-Logo.webp",
url: "images/EcvpYjvWQ34NglGi8ctDG.webp"
},
status: 0,
arranger: "Theodore",
type: "Some Type",
custodian: {
id: -1,
code: "ALLO",
name: "ALLO",
logo: {
kind: "PNG",
filename: "Allobank.png",
url: "images/7i6HRPlFQ31hZrRmErJOva.png"
},
description: "ALLO BANK INDONESIA"
} as Bank,
monitoring: {
id: -1,
code: "ALLO",
name: "ALLO",
logo: {
kind: "PNG",
filename: "Allobank.png",
url: "images/7i6HRPlFQ31hZrRmErJOva.png"
},
description: "ALLO BANK INDONESIA"
} as Bank,
launchedDate: "2022-02-14",
kseiNumber: "123123123",
amount: 60000000000,
min: 500000000,
max: 1000000000,
interest: 12,
tenor: 36,
disclaimer: "The best thing since sliced bread!",
prospectus: {
kind: "PDF",
filename: "dummy.pdf",
url: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
},
factSheet: {
kind: "PDF",
filename: "dummy.pdf",
url: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
}
}
const client = await import('@/common/api/axios')
client.axiosInstance.get = vi.fn().mockResolvedValue(data);
const product = await getProducts();
expect(client.axiosInstance.get).toHaveBeenCalled();
expect(product).toEqual(data);
})
}) |