Skip to content

Commit

Permalink
adding cache script before running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pellicceama committed Nov 3, 2022
1 parent c210f9b commit 2216494
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
"!dist/**/*.test.js"
],
"scripts": {
"index": "yarn ts-node ./src/index.ts",
"index": "ts-node ./src/index.ts",
"clean": "rimraf ./dist/ ./exec/",
"build": "yarn clean && tsc",
"preparePublish": "yarn build && npm version patch",
"test": "yarn build && ava --verbose",
"prepareTest": "yarn ts-node ./src/cache.ts",
"test": "yarn prepareTest && yarn build && ava --verbose",
"bundle": "yarn build && pkg . --out-dir ./exec/"
},
"devDependencies": {
Expand Down
14 changes: 14 additions & 0 deletions src/cache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { cloneOrPullRepoAndUpdateSubmodules } from "./utils";
import { REPO_CLONE_URL, DEFAULT_REPO_DISK_LOCATION, DEFAULT_TWA_DISK_LOCATION, TWA_REPO_CLONE_URL } from "./utils/constants";

async function main() {
console.log("Cloning map3xyz/assets repo... ahead of tests");
await Promise.all([
cloneOrPullRepoAndUpdateSubmodules(REPO_CLONE_URL, DEFAULT_REPO_DISK_LOCATION, true, "master"),
cloneOrPullRepoAndUpdateSubmodules(TWA_REPO_CLONE_URL, DEFAULT_TWA_DISK_LOCATION, true, "master"),
]);
}

main().catch(err => console.error(err));


15 changes: 13 additions & 2 deletions src/networks/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from "ava";
import { getAssetMapping, getNetworks, getNetworksWithAssets } from ".";
import { getAssetMapping, getAssetsForNetwork, getNetworks, getNetworksWithAssets } from ".";

test("networks includes ethereum", async (t) => {
const networks = await getNetworks();
Expand All @@ -19,4 +19,15 @@ test("networks with assets includes polygon", async (t) => {
test("networks with assets does not include Bitcoin", async (t) => {
const networks = await getNetworksWithAssets();
t.falsy(networks.find((n) => n.name === "Bitcoin"));
});
});

test("Get assets limits work", async t => {
const assets = await getAssetsForNetwork("ethereum", undefined, 1);
t.truthy(assets.length === 1);
})

test("Get assets identifier limits works", async t => {
const assets = await getAssetsForNetwork("ethereum", undefined, 1, 1, ['coinmarketcap']);
t.truthy(assets.length === 1);
t.truthy(assets[0].identifiers.coinmarketcap);
})

0 comments on commit 2216494

Please sign in to comment.