Fix test cases and improve test from custom modal
This commit is contained in:
parent
03c7d14b4b
commit
3346b96f18
27
src/components/CustomModal/__tests__/CustomModal.spec.ts
Normal file
27
src/components/CustomModal/__tests__/CustomModal.spec.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { mount } from "@vue/test-utils";
|
||||
import CustomModal from "../CustomModal.vue";
|
||||
|
||||
describe("CustomModal test", () => {
|
||||
test("Test custom modal when receive is redirect modal props as false", () => {
|
||||
const wrapper = mount(CustomModal, {
|
||||
props: {
|
||||
isRedirectModal: false,
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.html()).toContain("ATENÇÃO!");
|
||||
expect(wrapper.html()).toContain("Entendi");
|
||||
});
|
||||
|
||||
test("Test custom modal when receive is redirect modal props as true", () => {
|
||||
const wrapper = mount(CustomModal, {
|
||||
props: {
|
||||
isRedirectModal: true,
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.html()).toContain("Retomar a última compra?");
|
||||
expect(wrapper.html()).toContain("Não");
|
||||
expect(wrapper.html()).toContain("Sim");
|
||||
});
|
||||
});
|
@ -1,10 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { pix } from "../utils/QrCodePix";
|
||||
import { pix } from "@/utils/QrCodePix";
|
||||
import { ref } from "vue";
|
||||
import { debounce } from "@/utils/debounce";
|
||||
import CustomButton from "./CustomButton/CustomButton.vue";
|
||||
import CustomModal from "./CustomModal.vue";
|
||||
import api from "../services/index";
|
||||
import CustomButton from "@/components/CustomButton/CustomButton.vue";
|
||||
import CustomModal from "@/components//CustomModal/CustomModal.vue";
|
||||
import api from "@/services/index";
|
||||
|
||||
// props and store references
|
||||
const props = defineProps({
|
||||
|
@ -2,16 +2,15 @@
|
||||
import SearchComponent from "@/components/SearchComponent.vue";
|
||||
import LoadingComponent from "@/components/LoadingComponent/LoadingComponent.vue";
|
||||
import BuyConfirmedComponent from "@/components/BuyConfirmedComponent/BuyConfirmedComponent.vue";
|
||||
import { ref, onMounted, watch } from "vue";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useEtherStore } from "@/store/ether";
|
||||
import QrCodeComponent from "@/components/QrCodeComponent.vue";
|
||||
import CustomModal from "@/components/CustomModal.vue";
|
||||
import CustomModal from "@/components/CustomModal/CustomModal.vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { addLock, releaseLock } from "@/blockchain/buyerMethods";
|
||||
import {
|
||||
updateWalletStatus,
|
||||
listReleaseTransactionByWalletAddress,
|
||||
checkUnreleasedLocks,
|
||||
} from "@/blockchain/wallet";
|
||||
import { getNetworksLiquidity } from "@/blockchain/events";
|
||||
import type { Event } from "ethers";
|
||||
@ -27,7 +26,7 @@ const etherStore = useEtherStore();
|
||||
etherStore.setSellerView(false);
|
||||
|
||||
// States
|
||||
const { loadingLock, walletAddress, networkName } = storeToRefs(etherStore);
|
||||
const { loadingLock, walletAddress } = storeToRefs(etherStore);
|
||||
const flowStep = ref<Step>(Step.Search);
|
||||
const pixTarget = ref<number>();
|
||||
const tokenAmount = ref<number>();
|
||||
@ -87,18 +86,18 @@ const releaseTransaction = async (e2eId: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
const checkForUnreleasedLocks = async () => {
|
||||
const walletLocks = await checkUnreleasedLocks(walletAddress.value);
|
||||
if (walletLocks) {
|
||||
lockID.value = walletLocks.lockID;
|
||||
tokenAmount.value = walletLocks.pix.value;
|
||||
pixTarget.value = Number(walletLocks.pix.pixKey);
|
||||
showModal.value = true;
|
||||
} else {
|
||||
flowStep.value = Step.Search;
|
||||
showModal.value = false;
|
||||
}
|
||||
};
|
||||
// const checkForUnreleasedLocks = async () => {
|
||||
// const walletLocks = await checkUnreleasedLocks(walletAddress.value);
|
||||
// if (walletLocks) {
|
||||
// lockID.value = walletLocks.lockID;
|
||||
// tokenAmount.value = walletLocks.pix.value;
|
||||
// pixTarget.value = Number(walletLocks.pix.pixKey);
|
||||
// showModal.value = true;
|
||||
// } else {
|
||||
// flowStep.value = Step.Search;
|
||||
// showModal.value = false;
|
||||
// }
|
||||
// };
|
||||
|
||||
// if (walletAddress) {
|
||||
// await checkForUnreleasedLocks();
|
||||
|
Loading…
x
Reference in New Issue
Block a user