fixing lint

This commit is contained in:
brunoedcf 2023-01-27 21:08:32 -03:00
parent 588b513a0b
commit 16aa47061e
2 changed files with 89 additions and 84 deletions

View File

@ -1,105 +1,110 @@
import { expectTypeOf, it, expect, vi } from 'vitest' import { expectTypeOf, it, expect } from "vitest";
import { import {
getTokenAddress, getTokenAddress,
getP2PixAddress, getP2PixAddress,
getProviderUrl, getProviderUrl,
isPossibleNetwork, isPossibleNetwork,
possibleChains, possibleChains,
network2Chain, network2Chain,
} from '../addresses' } from "../addresses";
import { setActivePinia, createPinia } from 'pinia' import { setActivePinia, createPinia } from "pinia";
import { NetworkEnum } from "@/model/NetworkEnum"; import { NetworkEnum } from "@/model/NetworkEnum";
import { useEtherStore } from "@/store/ether"; import { useEtherStore } from "@/store/ether";
describe("addresses.ts types", () => { describe("addresses.ts types", () => {
it("My addresses.ts types work properly", () => {
expectTypeOf(getTokenAddress).toBeFunction();
expectTypeOf(getP2PixAddress).toBeFunction();
expectTypeOf(getProviderUrl).toBeFunction();
expectTypeOf(isPossibleNetwork).toBeFunction();
it("My addresses.ts types work properly", () =>{ expectTypeOf(possibleChains).toBeObject();
expectTypeOf(network2Chain).toBeObject();
expectTypeOf(getTokenAddress).toBeFunction() });
expectTypeOf(getP2PixAddress).toBeFunction() });
expectTypeOf(getProviderUrl).toBeFunction()
expectTypeOf(isPossibleNetwork).toBeFunction()
expectTypeOf(possibleChains).toBeObject()
expectTypeOf(network2Chain).toBeObject()
})
})
describe("addresses.ts functions", () => { describe("addresses.ts functions", () => {
beforeEach(() => {
setActivePinia(createPinia());
});
beforeEach(() => { it("getTokenAddress Ethereum", () => {
setActivePinia(createPinia()) const etherStore = useEtherStore();
}) etherStore.setNetworkName(NetworkEnum.ethereum);
expect(getTokenAddress()).toBe(
"0x294003F602c321627152c6b7DED3EAb5bEa853Ee"
);
});
it('getTokenAddress Ethereum', () => { it("getTokenAddress Polygon", () => {
const etherStore = useEtherStore(); const etherStore = useEtherStore();
etherStore.setNetworkName(NetworkEnum.ethereum) etherStore.setNetworkName(NetworkEnum.polygon);
expect(getTokenAddress()).toBe("0x294003F602c321627152c6b7DED3EAb5bEa853Ee") expect(getTokenAddress()).toBe(
}) "0x294003F602c321627152c6b7DED3EAb5bEa853Ee"
);
});
it('getTokenAddress Polygon', () => { it("getTokenAddress Default", () => {
const etherStore = useEtherStore(); expect(getTokenAddress()).toBe(
etherStore.setNetworkName(NetworkEnum.polygon) "0x294003F602c321627152c6b7DED3EAb5bEa853Ee"
expect(getTokenAddress()).toBe("0x294003F602c321627152c6b7DED3EAb5bEa853Ee") );
}) });
it('getTokenAddress Default', () => { it("getP2PixAddress Ethereum", () => {
expect(getTokenAddress()).toBe("0x294003F602c321627152c6b7DED3EAb5bEa853Ee") const etherStore = useEtherStore();
}) etherStore.setNetworkName(NetworkEnum.ethereum);
expect(getP2PixAddress()).toBe(
"0x5f3EFA9A90532914545CEf527C530658af87e196"
);
});
it('getP2PixAddress Ethereum', () => { it("getP2PixAddress Polygon", () => {
const etherStore = useEtherStore(); const etherStore = useEtherStore();
etherStore.setNetworkName(NetworkEnum.ethereum) etherStore.setNetworkName(NetworkEnum.polygon);
expect(getP2PixAddress()).toBe("0x5f3EFA9A90532914545CEf527C530658af87e196") expect(getP2PixAddress()).toBe(
}) "0x5f3EFA9A90532914545CEf527C530658af87e196"
);
});
it('getP2PixAddress Polygon', () => { it("getP2PixAddress Default", () => {
const etherStore = useEtherStore(); expect(getP2PixAddress()).toBe(
etherStore.setNetworkName(NetworkEnum.polygon) "0x5f3EFA9A90532914545CEf527C530658af87e196"
expect(getP2PixAddress()).toBe("0x5f3EFA9A90532914545CEf527C530658af87e196") );
}) });
it('getP2PixAddress Default', () => { it("getProviderUrl Ethereum", () => {
expect(getP2PixAddress()).toBe("0x5f3EFA9A90532914545CEf527C530658af87e196") const etherStore = useEtherStore();
}) etherStore.setNetworkName(NetworkEnum.ethereum);
expect(getProviderUrl()).toBe(import.meta.env.VITE_GOERLI_API_URL);
});
it('getProviderUrl Ethereum', () => { it("getProviderUrl Polygon", () => {
const etherStore = useEtherStore(); const etherStore = useEtherStore();
etherStore.setNetworkName(NetworkEnum.ethereum) etherStore.setNetworkName(NetworkEnum.polygon);
expect(getProviderUrl()).toBe(import.meta.env.VITE_GOERLI_API_URL) expect(getProviderUrl()).toBe(import.meta.env.VITE_MUMBAI_API_URL);
}) });
it('getProviderUrl Polygon', () => { it("getProviderUrl Default", () => {
const etherStore = useEtherStore(); expect(getProviderUrl()).toBe(import.meta.env.VITE_GOERLI_API_URL);
etherStore.setNetworkName(NetworkEnum.polygon) });
expect(getProviderUrl()).toBe(import.meta.env.VITE_MUMBAI_API_URL)
})
it('getProviderUrl Default', () => { it("isPossibleNetwork Returns", () => {
expect(getProviderUrl()).toBe(import.meta.env.VITE_GOERLI_API_URL) const etherStore = useEtherStore();
}) etherStore.setNetworkName(NetworkEnum.ethereum);
expect(isPossibleNetwork("0x5")).toBe(true);
expect(isPossibleNetwork("5")).toBe(true);
expect(isPossibleNetwork("0x13881")).toBe(true);
expect(isPossibleNetwork("80001")).toBe(true);
it('isPossibleNetwork Returns', () => { expect(isPossibleNetwork("")).toBe(false);
const etherStore = useEtherStore(); expect(isPossibleNetwork(" ")).toBe(false);
etherStore.setNetworkName(NetworkEnum.ethereum) expect(isPossibleNetwork("0x55")).toBe(false);
expect(isPossibleNetwork("0x5")).toBe(true) });
expect(isPossibleNetwork("5")).toBe(true) });
expect(isPossibleNetwork("0x13881")).toBe(true)
expect(isPossibleNetwork("80001")).toBe(true)
expect(isPossibleNetwork("")).toBe(false)
expect(isPossibleNetwork(" ")).toBe(false)
expect(isPossibleNetwork("0x55")).toBe(false)
})
})
describe("addresses.ts Unset Store", () => { describe("addresses.ts Unset Store", () => {
it('getProviderUrl Unset', () => { it("getProviderUrl Unset", () => {
expect(getProviderUrl()).toBe(undefined) expect(getProviderUrl()).toBe(undefined);
}) });
}) });