python-proxy-scraper-client
Version:
A TypeScript client for interacting with a Python proxy scraper service
133 lines (132 loc) • 7.22 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
/// <reference types="jest" />
const insightx_client_1 = require("./insightx-client");
const testCases = [
{
chainId: "1",
address: "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984" // UNI token
},
{
chainId: "1",
address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" // WETH
},
{
chainId: "solana",
address: "4rwPNRSFgcS7EGphFdX7VwXuhjZGxph7gYyb7Zp2pump" // Solana token
}
];
describe('InsightX API Tests', () => {
testCases.forEach(({ chainId, address }) => {
describe(`${chainId} chain tests for ${address}`, () => {
describe('getTimestamps', () => {
test.concurrent('should return timestamps with correct structure', async () => {
const client = new insightx_client_1.InsightXClient();
const response = await client.getTimestamps(chainId, address);
expect(Array.isArray(response)).toBe(true);
for (const timestamp of response) {
console.log(typeof timestamp);
}
expect(response.every(timestamp => typeof timestamp === 'number')).toBe(true);
}, 30000);
});
describe('getBubblemap', () => {
test.concurrent('should return bubblemap data with correct structure', async () => {
const client = new insightx_client_1.InsightXClient();
const response = await client.getBubblemap(chainId, address);
// Check main structure
expect(response).toHaveProperty('nodes');
expect(response).toHaveProperty('links');
expect(response).toHaveProperty('token_links');
expect(response).toHaveProperty('categories');
expect(response).toHaveProperty('views');
expect(response).toHaveProperty('proxy_available');
// Check nodes structure
if (response.nodes.length > 0) {
const node = response.nodes[0];
expect(node).toHaveProperty('name');
expect(node).toHaveProperty('amount');
expect(node).toHaveProperty('is_tax');
expect(node).toHaveProperty('address');
expect(node).toHaveProperty('is_burn');
expect(node).toHaveProperty('is_lock');
expect(node).toHaveProperty('is_pair');
expect(node).toHaveProperty('is_team');
expect(node).toHaveProperty('is_proxy');
expect(node).toHaveProperty('amount_usd');
expect(node).toHaveProperty('is_presale');
expect(node).toHaveProperty('percentage');
expect(node).toHaveProperty('is_contract');
expect(node).toHaveProperty('is_exchange');
}
// Check links structure
if (response.links.length > 0) {
const link = response.links[0];
expect(link).toHaveProperty('source');
expect(link).toHaveProperty('target');
expect(link).toHaveProperty('forward');
expect(link).toHaveProperty('backward');
}
// Check token_links structure
if (response.token_links.length > 0) {
const tokenLink = response.token_links[0];
expect(tokenLink).toHaveProperty('address');
expect(tokenLink).toHaveProperty('symbol');
expect(tokenLink).toHaveProperty('name');
expect(tokenLink).toHaveProperty('logo');
expect(tokenLink).toHaveProperty('links');
if (tokenLink.links.length > 0) {
const link = tokenLink.links[0];
expect(link).toHaveProperty('source');
expect(link).toHaveProperty('target');
expect(link).toHaveProperty('forward');
expect(link).toHaveProperty('backward');
}
}
// Check categories structure
if (response.categories.length > 0) {
const category = response.categories[0];
expect(category).toHaveProperty('name');
expect(category).toHaveProperty('size');
expect(category).toHaveProperty('nodes');
}
}, 30000);
});
describe('getBubblemapByTimestamp', () => {
test.concurrent('should return timestamped bubblemap data with correct structure', async () => {
const client = new insightx_client_1.InsightXClient();
const timestamps = await client.getTimestamps(chainId, address);
if (timestamps.length > 0) {
const timestamp = timestamps[0];
const response = await client.getBubblemapByTimestamp(chainId, address, timestamp.toString());
// Check main structure
expect(response).toHaveProperty('nodes');
expect(response).toHaveProperty('links');
expect(response).toHaveProperty('token_links');
expect(response).toHaveProperty('categories');
expect(response).toHaveProperty('views');
expect(response).toHaveProperty('proxy_available');
// Check nodes structure
if (response.nodes.length > 0) {
const node = response.nodes[0];
expect(node).toHaveProperty('name');
expect(node).toHaveProperty('amount');
expect(node).toHaveProperty('is_tax');
expect(node).toHaveProperty('address');
expect(node).toHaveProperty('is_burn');
expect(node).toHaveProperty('is_lock');
expect(node).toHaveProperty('is_pair');
expect(node).toHaveProperty('is_team');
expect(node).toHaveProperty('is_proxy');
expect(node).toHaveProperty('amount_usd');
expect(node).toHaveProperty('is_presale');
expect(node).toHaveProperty('percentage');
expect(node).toHaveProperty('is_contract');
expect(node).toHaveProperty('is_exchange');
}
}
}, 30000);
});
});
});
});
;