mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
Update test
This commit is contained in:
parent
0f2a2b997b
commit
99c59d87a5
|
@ -1,6 +1,6 @@
|
|||
import * as fs from "fs"
|
||||
import * as path from "path"
|
||||
|
||||
import { ValidatorModel } from "./models";
|
||||
const axios = require('axios')
|
||||
const Web3 = require('web3')
|
||||
const web3 = new Web3('ws://localhost:8546');
|
||||
|
@ -125,4 +125,11 @@ export const calculateAspectRatioFit = (srcWidth: number, srcHeight: number, max
|
|||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const isValidatorHasAllKeys = (val: ValidatorModel): boolean => {
|
||||
return typeof val.id === "string"
|
||||
&& typeof val.name === "string"
|
||||
&& typeof val.description === "string"
|
||||
&& typeof val.website === "string"
|
||||
}
|
||||
|
|
|
@ -23,9 +23,10 @@ import {
|
|||
getChainBlacklistPath,
|
||||
mapList,
|
||||
findFiles,
|
||||
isValidJSON
|
||||
isValidJSON,
|
||||
isValidatorHasAllKeys
|
||||
} from "./helpers"
|
||||
|
||||
import { ValidatorModel } from "./models";
|
||||
enum TickerType {
|
||||
Token = "token",
|
||||
Coin = "coin"
|
||||
|
@ -135,16 +136,9 @@ describe(`Test "blockchains" folder`, () => {
|
|||
|
||||
stakingChains.forEach(chain => {
|
||||
const validatorsList = JSON.parse(readFileSync(getChainValidatorsListPath(chain)))
|
||||
|
||||
test(`Make sure ${chain} validators list has correct structure`, () => {
|
||||
validatorsList.forEach(val => {
|
||||
const keys = Object.keys(val)
|
||||
expect(keys.length, `Wrong keys amount`).toBeGreaterThanOrEqual(4)
|
||||
|
||||
keys.forEach(key => {
|
||||
const type = typeof key
|
||||
expect(type, `Wrong key type`).toBe("string")
|
||||
})
|
||||
validatorsList.forEach((val: ValidatorModel) => {
|
||||
expect(isValidatorHasAllKeys(val), `Come key and/or type missing for validator ${JSON.stringify(val)}`).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
6
src/test/models.ts
Normal file
6
src/test/models.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
export interface ValidatorModel {
|
||||
id: string,
|
||||
name: string,
|
||||
description: string,
|
||||
website: string,
|
||||
}
|
Loading…
Reference in New Issue
Block a user