Removed all tests and test libraries.
This commit is contained in:
parent
81c8b04c7a
commit
2e246f7560
10922
package-lock.json
generated
Normal file
10922
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -5,9 +5,7 @@
|
|||||||
"start": "vite --host=0.0.0.0 --port 3000",
|
"start": "vite --host=0.0.0.0 --port 3000",
|
||||||
"build": "run-p type-check build-only",
|
"build": "run-p type-check build-only",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "vitest",
|
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
"coverage": "vitest run --coverage",
|
|
||||||
"build-only": "vite build",
|
"build-only": "vite build",
|
||||||
"type-check": "vue-tsc --skipLibCheck --noEmit",
|
"type-check": "vue-tsc --skipLibCheck --noEmit",
|
||||||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore --fix",
|
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore --fix",
|
||||||
@ -23,7 +21,6 @@
|
|||||||
"alchemy-sdk": "^2.3.0",
|
"alchemy-sdk": "^2.3.0",
|
||||||
"axios": "^1.2.1",
|
"axios": "^1.2.1",
|
||||||
"crc": "^3.8.0",
|
"crc": "^3.8.0",
|
||||||
"ethers": "^6.13.4",
|
|
||||||
"marked": "^4.2.12",
|
"marked": "^4.2.12",
|
||||||
"qrcode": "^1.5.1",
|
"qrcode": "^1.5.1",
|
||||||
"viem": "^2.31.3",
|
"viem": "^2.31.3",
|
||||||
@ -37,29 +34,24 @@
|
|||||||
"@babel/preset-typescript": "^7.18.6",
|
"@babel/preset-typescript": "^7.18.6",
|
||||||
"@rushstack/eslint-patch": "^1.1.4",
|
"@rushstack/eslint-patch": "^1.1.4",
|
||||||
"@types/crc": "^3.8.0",
|
"@types/crc": "^3.8.0",
|
||||||
"@types/jest": "^27.0.0",
|
|
||||||
"@types/marked": "^4.0.8",
|
"@types/marked": "^4.0.8",
|
||||||
"@types/node": "^16.11.68",
|
"@types/node": "^16.11.68",
|
||||||
"@types/qrcode": "^1.5.0",
|
"@types/qrcode": "^1.5.0",
|
||||||
"@types/vue-markdown": "^2.2.1",
|
"@types/vue-markdown": "^2.2.1",
|
||||||
"@vitejs/plugin-vue": "^3.1.2",
|
"@vitejs/plugin-vue": "^3.1.2",
|
||||||
"@vitejs/plugin-vue-jsx": "^2.0.1",
|
"@vitejs/plugin-vue-jsx": "^2.0.1",
|
||||||
"@vitest/coverage-c8": "^0.28.2",
|
|
||||||
"@vue/eslint-config-prettier": "^7.0.0",
|
"@vue/eslint-config-prettier": "^7.0.0",
|
||||||
"@vue/eslint-config-typescript": "^11.0.0",
|
"@vue/eslint-config-typescript": "^11.0.0",
|
||||||
"@vue/test-utils": "^2.2.7",
|
|
||||||
"@vue/tsconfig": "^0.1.3",
|
"@vue/tsconfig": "^0.1.3",
|
||||||
"autoprefixer": "^10.4.12",
|
"autoprefixer": "^10.4.12",
|
||||||
"eslint": "^8.22.0",
|
"eslint": "^8.22.0",
|
||||||
"eslint-plugin-vue": "^9.3.0",
|
"eslint-plugin-vue": "^9.3.0",
|
||||||
"jsdom": "^21.1.0",
|
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"postcss": "^8.4.18",
|
"postcss": "^8.4.18",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"tailwindcss": "^3.2.1",
|
"tailwindcss": "^3.2.1",
|
||||||
"typescript": "~5.8.2",
|
"typescript": "~5.8.2",
|
||||||
"vite": "^3.1.8",
|
"vite": "^3.1.8",
|
||||||
"vitest": "^0.28.1",
|
|
||||||
"vue-tsc": "^2.2.8"
|
"vue-tsc": "^2.2.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,93 +0,0 @@
|
|||||||
import { expectTypeOf, it, expect } from "vitest";
|
|
||||||
import {
|
|
||||||
getTokenAddress,
|
|
||||||
getP2PixAddress,
|
|
||||||
getProviderUrl,
|
|
||||||
isPossibleNetwork,
|
|
||||||
} from "../addresses";
|
|
||||||
|
|
||||||
import { NetworkEnum, TokenEnum } from "@/model/NetworkEnum";
|
|
||||||
import { useUser } from "@/composables/useUser";
|
|
||||||
|
|
||||||
describe("addresses.ts types", () => {
|
|
||||||
it("My addresses.ts types work properly", () => {
|
|
||||||
expectTypeOf(getTokenAddress).toBeFunction();
|
|
||||||
expectTypeOf(getP2PixAddress).toBeFunction();
|
|
||||||
expectTypeOf(getProviderUrl).toBeFunction();
|
|
||||||
expectTypeOf(isPossibleNetwork).toBeFunction();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("addresses.ts functions", () => {
|
|
||||||
it("getTokenAddress Ethereum", () => {
|
|
||||||
const user = useUser();
|
|
||||||
user.setNetworkId(11155111);
|
|
||||||
expect(getTokenAddress(TokenEnum.BRZ)).toBe(
|
|
||||||
"0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("getTokenAddress Rootstock", () => {
|
|
||||||
const user = useUser();
|
|
||||||
user.setNetworkId(30);
|
|
||||||
expect(getTokenAddress(TokenEnum.BRZ)).toBe(
|
|
||||||
"0xfE841c74250e57640390f46d914C88d22C51e82e"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("getTokenAddress Default", () => {
|
|
||||||
expect(getTokenAddress(TokenEnum.BRZ)).toBe(
|
|
||||||
"0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("getP2PixAddress Ethereum", () => {
|
|
||||||
const user = useUser();
|
|
||||||
user.setNetworkId(11155111);
|
|
||||||
expect(getP2PixAddress()).toBe(
|
|
||||||
"0x2414817FF64A114d91eCFA16a834d3fCf69103d4"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("getP2PixAddress Rootstock", () => {
|
|
||||||
const user = useUser();
|
|
||||||
user.setNetworkId(30);
|
|
||||||
expect(getP2PixAddress()).toBe(
|
|
||||||
"0x98ba35eb14b38D6Aa709338283af3e922476dE34"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("getP2PixAddress Default", () => {
|
|
||||||
expect(getP2PixAddress()).toBe(
|
|
||||||
"0x2414817FF64A114d91eCFA16a834d3fCf69103d4"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("getProviderUrl Ethereum", () => {
|
|
||||||
const user = useUser();
|
|
||||||
user.setNetworkId(11155111);
|
|
||||||
expect(getProviderUrl()).toBe(import.meta.env.VITE_GOERLI_API_URL);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("getProviderUrl Rootstock", () => {
|
|
||||||
const user = useUser();
|
|
||||||
user.setNetworkId(30);
|
|
||||||
expect(getProviderUrl()).toBe(import.meta.env.VITE_ROOTSTOCK_API_URL);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("getProviderUrl Default", () => {
|
|
||||||
expect(getProviderUrl()).toBe(import.meta.env.VITE_GOERLI_API_URL);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("isPossibleNetwork Returns", () => {
|
|
||||||
const user = useUser();
|
|
||||||
user.setNetworkId(11155111);
|
|
||||||
expect(isPossibleNetwork(0x5 as NetworkEnum)).toBe(true);
|
|
||||||
expect(isPossibleNetwork(5 as NetworkEnum)).toBe(true);
|
|
||||||
expect(isPossibleNetwork(0x13881 as NetworkEnum)).toBe(true);
|
|
||||||
expect(isPossibleNetwork(80001 as NetworkEnum)).toBe(true);
|
|
||||||
|
|
||||||
expect(isPossibleNetwork(NaN as NetworkEnum)).toBe(false);
|
|
||||||
expect(isPossibleNetwork(0x55 as NetworkEnum)).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,32 +0,0 @@
|
|||||||
import { mount } from "@vue/test-utils";
|
|
||||||
import BuyConfirmedComponent from "../BuyConfirmedComponent.vue";
|
|
||||||
|
|
||||||
describe("BuyConfirmedComponent.vue", async () => {
|
|
||||||
const wrapper = mount(BuyConfirmedComponent, {
|
|
||||||
props: {
|
|
||||||
tokenAmount: 1,
|
|
||||||
isCurrentStep: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// test("Test component Header Text", () => {
|
|
||||||
// expect(wrapper.html()).toContain("Os tokens já foram transferidos");
|
|
||||||
// expect(wrapper.html()).toContain("para a sua carteira!");
|
|
||||||
// });
|
|
||||||
|
|
||||||
// test("Test component Container Text", () => {
|
|
||||||
// expect(wrapper.html()).toContain("Tokens recebidos");
|
|
||||||
// expect(wrapper.html()).toContain("BRZ");
|
|
||||||
// expect(wrapper.html()).toContain("Não encontrou os tokens?");
|
|
||||||
// expect(wrapper.html()).toContain("Clique no botão abaixo para");
|
|
||||||
// expect(wrapper.html()).toContain("cadastrar o BRZ em sua carteira.");
|
|
||||||
// });
|
|
||||||
|
|
||||||
test("Test makeAnotherTransactionEmit", async () => {
|
|
||||||
wrapper.vm.$emit("makeAnotherTransaction");
|
|
||||||
|
|
||||||
await wrapper.vm.$nextTick();
|
|
||||||
|
|
||||||
expect(wrapper.emitted("makeAnotherTransaction")).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,27 +0,0 @@
|
|||||||
import { mount } from "@vue/test-utils";
|
|
||||||
import CustomButton from "../CustomButton.vue";
|
|
||||||
|
|
||||||
describe("CustomButton.vue", () => {
|
|
||||||
test("Test button content", () => {
|
|
||||||
const wrapper = mount(CustomButton, {
|
|
||||||
props: {
|
|
||||||
text: "Testing",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(wrapper.html()).toContain("Testing");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Test if disabled props works", () => {
|
|
||||||
const wrapper = mount(CustomButton, {
|
|
||||||
props: {
|
|
||||||
isDisabled: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
//@ts-ignore
|
|
||||||
const button = wrapper.find(".button") as HTMLButtonElement;
|
|
||||||
//@ts-ignore
|
|
||||||
expect(button.element.disabled).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,27 +0,0 @@
|
|||||||
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,85 +0,0 @@
|
|||||||
import { describe, expect, beforeEach } from "vitest";
|
|
||||||
import { mount } from "@vue/test-utils";
|
|
||||||
import ListingComponent from "../ListingComponent.vue";
|
|
||||||
import { useUser } from "@/composables/useUser";
|
|
||||||
import { MockValidDeposits } from "@/model/mock/ValidDepositMock";
|
|
||||||
import { MockWalletTransactions } from "@/model/mock/WalletTransactionMock";
|
|
||||||
|
|
||||||
describe("ListingComponent.vue", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
useUser().setLoadingWalletTransactions(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Test Message when an empty array is received", () => {
|
|
||||||
const wrapper = mount(ListingComponent, {
|
|
||||||
props: {
|
|
||||||
validDeposits: [],
|
|
||||||
walletTransactions: [],
|
|
||||||
activeLockAmount: 0,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(wrapper.html()).toContain("Não há nenhuma transação anterior");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Test number of elements in the list first render", () => {
|
|
||||||
const wrapper = mount(ListingComponent, {
|
|
||||||
props: {
|
|
||||||
validDeposits: [],
|
|
||||||
walletTransactions: MockWalletTransactions,
|
|
||||||
activeLockAmount: 0,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const elements = wrapper.findAll(".item-container");
|
|
||||||
|
|
||||||
expect(elements).toHaveLength(3);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Test load more button behavior", async () => {
|
|
||||||
const wrapper = mount(ListingComponent, {
|
|
||||||
props: {
|
|
||||||
validDeposits: MockValidDeposits,
|
|
||||||
walletTransactions: MockWalletTransactions,
|
|
||||||
activeLockAmount: 0,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const btn = wrapper.find("button");
|
|
||||||
|
|
||||||
let elements = wrapper.findAll(".item-container");
|
|
||||||
expect(elements).toHaveLength(3);
|
|
||||||
|
|
||||||
await btn.trigger("click");
|
|
||||||
|
|
||||||
elements = wrapper.findAll(".item-container");
|
|
||||||
|
|
||||||
expect(elements).toHaveLength(5);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Test withdraw offer button emit", async () => {
|
|
||||||
const wrapper = mount(ListingComponent, {
|
|
||||||
props: {
|
|
||||||
validDeposits: MockValidDeposits,
|
|
||||||
walletTransactions: MockWalletTransactions,
|
|
||||||
activeLockAmount: 0,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
wrapper.vm.$emit("depositWithdrawn");
|
|
||||||
|
|
||||||
await wrapper.vm.$nextTick();
|
|
||||||
|
|
||||||
expect(wrapper.emitted("depositWithdrawn")).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Test should render lock info when active lock amount is greater than 0", () => {
|
|
||||||
const wrapper = mount(ListingComponent, {
|
|
||||||
props: {
|
|
||||||
validDeposits: MockValidDeposits,
|
|
||||||
walletTransactions: [],
|
|
||||||
activeLockAmount: 50,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(wrapper.html()).toContain("com 50.00 BRZ em lock");
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,27 +0,0 @@
|
|||||||
import { mount } from "@vue/test-utils";
|
|
||||||
import LoadingComponent from "../LoadingComponent.vue";
|
|
||||||
|
|
||||||
describe("Loading.vue", () => {
|
|
||||||
test("Test loading content with received props", () => {
|
|
||||||
const wrapper = mount(LoadingComponent, {
|
|
||||||
props: {
|
|
||||||
title: "MockTitle",
|
|
||||||
message: "MockMessage",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(wrapper.html()).toContain("MockTitle");
|
|
||||||
expect(wrapper.html()).toContain("MockMessage");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Test default text if props title isnt passed", () => {
|
|
||||||
const wrapper = mount(LoadingComponent, {
|
|
||||||
props: {
|
|
||||||
message: "MockMessage",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(wrapper.html()).toContain("Confirme em sua carteira");
|
|
||||||
expect(wrapper.html()).toContain("MockMessage");
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,21 +0,0 @@
|
|||||||
import { describe, it, expect } from "vitest";
|
|
||||||
import { mount } from "@vue/test-utils";
|
|
||||||
import TopBar from "../TopBar.vue";
|
|
||||||
|
|
||||||
describe("TopBar.vue", () => {
|
|
||||||
it("should render connect wallet button", () => {
|
|
||||||
const wrapper = mount(TopBar);
|
|
||||||
expect(wrapper.html()).toContain("Conectar carteira");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should render button to change to seller view when in buyer screen", () => {
|
|
||||||
const wrapper = mount(TopBar);
|
|
||||||
expect(wrapper.html()).toContain("Quero vender");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should render the P2Pix logo correctly", () => {
|
|
||||||
const wrapper = mount(TopBar);
|
|
||||||
const img = wrapper.findAll(".logo");
|
|
||||||
expect(img.length).toBe(2);
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,120 +0,0 @@
|
|||||||
import { vi } from "vitest";
|
|
||||||
|
|
||||||
export const MockEvents = [
|
|
||||||
{
|
|
||||||
blockNumber: 1,
|
|
||||||
blockHash: "0x8",
|
|
||||||
transactionIndex: 1,
|
|
||||||
removed: false,
|
|
||||||
address: "0x0",
|
|
||||||
data: "0x0",
|
|
||||||
topics: ["0x0", "0x0"],
|
|
||||||
transactionHash: "0x0",
|
|
||||||
logIndex: 1,
|
|
||||||
event: "DepositAdded",
|
|
||||||
eventSignature: "DepositAdded(address,uint256,address,uint256)",
|
|
||||||
args: [
|
|
||||||
"0x0",
|
|
||||||
{
|
|
||||||
type: "BigNumber",
|
|
||||||
hex: "0x00",
|
|
||||||
},
|
|
||||||
"0x0",
|
|
||||||
{
|
|
||||||
type: "BigNumber",
|
|
||||||
hex: "0x6c6b935b8bbd400000",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
getBlock: vi.fn(),
|
|
||||||
removeListener: vi.fn(),
|
|
||||||
getTransaction: vi.fn(),
|
|
||||||
getTransactionReceipt: vi.fn(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
blockNumber: 2,
|
|
||||||
blockHash: "0x8",
|
|
||||||
transactionIndex: 2,
|
|
||||||
removed: false,
|
|
||||||
address: "0x0",
|
|
||||||
data: "0x0",
|
|
||||||
topics: ["0x0", "0x0"],
|
|
||||||
transactionHash: "0x0",
|
|
||||||
logIndex: 2,
|
|
||||||
event: "LockAdded",
|
|
||||||
eventSignature: "LockAdded(address,uint256,address,uint256)",
|
|
||||||
args: [
|
|
||||||
"0x0",
|
|
||||||
{
|
|
||||||
type: "BigNumber",
|
|
||||||
hex: "0x00",
|
|
||||||
},
|
|
||||||
"0x0",
|
|
||||||
{
|
|
||||||
type: "BigNumber",
|
|
||||||
hex: "0x6c6b935b8bbd400000",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
getBlock: vi.fn(),
|
|
||||||
removeListener: vi.fn(),
|
|
||||||
getTransaction: vi.fn(),
|
|
||||||
getTransactionReceipt: vi.fn(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
blockNumber: 3,
|
|
||||||
blockHash: "0x8",
|
|
||||||
transactionIndex: 3,
|
|
||||||
removed: false,
|
|
||||||
address: "0x0",
|
|
||||||
data: "0x0",
|
|
||||||
topics: ["0x0", "0x0"],
|
|
||||||
transactionHash: "0x0",
|
|
||||||
logIndex: 3,
|
|
||||||
event: "LockReleased",
|
|
||||||
eventSignature: "LockReleased(address,uint256,address,uint256)",
|
|
||||||
args: [
|
|
||||||
"0x0",
|
|
||||||
{
|
|
||||||
type: "BigNumber",
|
|
||||||
hex: "0x00",
|
|
||||||
},
|
|
||||||
"0x0",
|
|
||||||
{
|
|
||||||
type: "BigNumber",
|
|
||||||
hex: "0x6c6b935b8bbd400000",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
getBlock: vi.fn(),
|
|
||||||
removeListener: vi.fn(),
|
|
||||||
getTransaction: vi.fn(),
|
|
||||||
getTransactionReceipt: vi.fn(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
blockNumber: 4,
|
|
||||||
blockHash: "0x8",
|
|
||||||
transactionIndex: 4,
|
|
||||||
removed: false,
|
|
||||||
address: "0x0",
|
|
||||||
data: "0x0",
|
|
||||||
topics: ["0x0", "0x0"],
|
|
||||||
transactionHash: "0x0",
|
|
||||||
logIndex: 4,
|
|
||||||
event: "LockReleased",
|
|
||||||
eventSignature: "LockReleased(address,uint256,address,uint256)",
|
|
||||||
args: [
|
|
||||||
"0x0",
|
|
||||||
{
|
|
||||||
type: "BigNumber",
|
|
||||||
hex: "0x00",
|
|
||||||
},
|
|
||||||
"0x0",
|
|
||||||
{
|
|
||||||
type: "BigNumber",
|
|
||||||
hex: "0x6c6b935b8bbd400000",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
getBlock: vi.fn(),
|
|
||||||
removeListener: vi.fn(),
|
|
||||||
getTransaction: vi.fn(),
|
|
||||||
getTransactionReceipt: vi.fn(),
|
|
||||||
},
|
|
||||||
];
|
|
@ -1,45 +0,0 @@
|
|||||||
import type { ValidDeposit } from "../ValidDeposit";
|
|
||||||
import { NetworkEnum } from "@/model/NetworkEnum";
|
|
||||||
|
|
||||||
export const MockValidDeposits: ValidDeposit[] = [
|
|
||||||
{
|
|
||||||
blockNumber: 1,
|
|
||||||
token: "1",
|
|
||||||
remaining: 70,
|
|
||||||
seller: "mockedSellerAddress",
|
|
||||||
participantID: "123456789",
|
|
||||||
network: NetworkEnum.sepolia,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
blockNumber: 2,
|
|
||||||
token: "2",
|
|
||||||
remaining: 200,
|
|
||||||
seller: "mockedSellerAddress",
|
|
||||||
participantID: "123456789",
|
|
||||||
network: NetworkEnum.sepolia,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
blockNumber: 3,
|
|
||||||
token: "3",
|
|
||||||
remaining: 1250,
|
|
||||||
seller: "mockedSellerAddress",
|
|
||||||
participantID: "123456789",
|
|
||||||
network: NetworkEnum.sepolia,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
blockNumber: 4,
|
|
||||||
token: "4",
|
|
||||||
remaining: 4000,
|
|
||||||
seller: "mockedSellerAddress",
|
|
||||||
participantID: "123456789",
|
|
||||||
network: NetworkEnum.sepolia,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
blockNumber: 5,
|
|
||||||
token: "5",
|
|
||||||
remaining: 2000,
|
|
||||||
seller: "mockedSellerAddress",
|
|
||||||
participantID: "123456789",
|
|
||||||
network: NetworkEnum.sepolia,
|
|
||||||
},
|
|
||||||
];
|
|
@ -1,54 +0,0 @@
|
|||||||
import type { WalletTransaction } from "../WalletTransaction";
|
|
||||||
|
|
||||||
export const MockWalletTransactions: WalletTransaction[] = [
|
|
||||||
{
|
|
||||||
blockNumber: 1,
|
|
||||||
token: "1",
|
|
||||||
amount: 70,
|
|
||||||
seller: "mockedSellerAddress",
|
|
||||||
buyer: "mockedBuyerAddress",
|
|
||||||
event: "Deposit",
|
|
||||||
lockStatus: 0,
|
|
||||||
transactionHash: "1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
blockNumber: 2,
|
|
||||||
token: "2",
|
|
||||||
amount: 200,
|
|
||||||
seller: "mockedSellerAddress",
|
|
||||||
buyer: "mockedBuyerAddress",
|
|
||||||
event: "Lock",
|
|
||||||
lockStatus: 1,
|
|
||||||
transactionHash: "2",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
blockNumber: 3,
|
|
||||||
token: "3",
|
|
||||||
amount: 1250,
|
|
||||||
seller: "mockedSellerAddress",
|
|
||||||
buyer: "mockedBuyerAddress",
|
|
||||||
event: "Release",
|
|
||||||
lockStatus: 2,
|
|
||||||
transactionHash: "3",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
blockNumber: 4,
|
|
||||||
token: "4",
|
|
||||||
amount: 4000,
|
|
||||||
seller: "mockedSellerAddress",
|
|
||||||
buyer: "mockedBuyerAddress",
|
|
||||||
event: "Deposit",
|
|
||||||
lockStatus: 0,
|
|
||||||
transactionHash: "4",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
blockNumber: 5,
|
|
||||||
token: "5",
|
|
||||||
amount: 2000,
|
|
||||||
seller: "mockedSellerAddress",
|
|
||||||
buyer: "mockedBuyerAddress",
|
|
||||||
event: "Deposit",
|
|
||||||
lockStatus: 3,
|
|
||||||
transactionHash: "5",
|
|
||||||
},
|
|
||||||
];
|
|
@ -1,24 +0,0 @@
|
|||||||
import { it, expect, vi, type Mock } from "vitest";
|
|
||||||
import { debounce } from "../debounce";
|
|
||||||
|
|
||||||
vi.useFakeTimers();
|
|
||||||
|
|
||||||
describe("debounce function test", () => {
|
|
||||||
let mockFunction: Mock;
|
|
||||||
let debounceFunction: Function;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
mockFunction = vi.fn();
|
|
||||||
debounceFunction = debounce(mockFunction, 1000);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("debounce function will be executed just once", () => {
|
|
||||||
for (let i = 0; i < 100; i++) {
|
|
||||||
debounceFunction();
|
|
||||||
}
|
|
||||||
|
|
||||||
vi.runAllTimers();
|
|
||||||
|
|
||||||
expect(mockFunction).toBeCalledTimes(1);
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,12 +0,0 @@
|
|||||||
import { it, expect } from "vitest";
|
|
||||||
import { decimalCount } from "../decimalCount";
|
|
||||||
|
|
||||||
describe("decimalCount function test", () => {
|
|
||||||
it("decimalCount should return length 1 of decimal", () => {
|
|
||||||
expect(decimalCount("4.1")).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("decimalCount should return length 0 because no decimal found", () => {
|
|
||||||
expect(decimalCount("5")).toEqual(0);
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,25 +0,0 @@
|
|||||||
import { MockValidDeposits } from "@/model/mock/ValidDepositMock";
|
|
||||||
import { it, expect, vi } from "vitest";
|
|
||||||
import { verifyNetworkLiquidity } from "../networkLiquidity";
|
|
||||||
|
|
||||||
vi.useFakeTimers();
|
|
||||||
|
|
||||||
describe("verifyNetworkLiquidity function test", () => {
|
|
||||||
it("verifyNetworkLiquidity should return an element from valid deposit list when searching for other deposits", () => {
|
|
||||||
const liquidityElement = verifyNetworkLiquidity(
|
|
||||||
MockValidDeposits[0].remaining,
|
|
||||||
"strangeWalletAddress",
|
|
||||||
MockValidDeposits
|
|
||||||
);
|
|
||||||
expect(liquidityElement).toEqual(MockValidDeposits[0]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("verifyNetworkLiquidity should return undefined when all deposits on valid deposit list match connected wallet addres", () => {
|
|
||||||
const liquidityElement = verifyNetworkLiquidity(
|
|
||||||
MockValidDeposits[0].remaining,
|
|
||||||
MockValidDeposits[0].seller,
|
|
||||||
[MockValidDeposits[0]]
|
|
||||||
);
|
|
||||||
expect(liquidityElement).toEqual(undefined);
|
|
||||||
});
|
|
||||||
});
|
|
@ -2,7 +2,6 @@
|
|||||||
"extends": "@vue/tsconfig/tsconfig.node.json",
|
"extends": "@vue/tsconfig/tsconfig.node.json",
|
||||||
"include": [
|
"include": [
|
||||||
"vite.config.*",
|
"vite.config.*",
|
||||||
"vitest.config.*",
|
|
||||||
"cypress.config.*",
|
"cypress.config.*",
|
||||||
"playwright.config.*"
|
"playwright.config.*"
|
||||||
],
|
],
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"types": [
|
"types": [
|
||||||
"jest",
|
|
||||||
"node"
|
"node"
|
||||||
],
|
],
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { fileURLToPath, URL } from "node:url";
|
import { fileURLToPath, URL } from "node:url";
|
||||||
|
|
||||||
import { defineConfig } from "vitest/config";
|
import { defineConfig } from "vite";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
import vueJsx from "@vitejs/plugin-vue-jsx";
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
||||||
import svgLoader from "vite-svg-loader";
|
import svgLoader from "vite-svg-loader";
|
||||||
@ -21,17 +21,6 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
test: {
|
|
||||||
globals: true,
|
|
||||||
environment: "jsdom",
|
|
||||||
coverage: {
|
|
||||||
provider: "c8",
|
|
||||||
all: true,
|
|
||||||
src: ["./src"],
|
|
||||||
exclude: ["model/**", "**/__tests__/**"],
|
|
||||||
reporter: ["text", "lcov", "html"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plugins: [vue(), vueJsx(), svgLoader()],
|
plugins: [vue(), vueJsx(), svgLoader()],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user