Skip to content

Commit

Permalink
tests: generate tests (#69)
Browse files Browse the repository at this point in the history
* tests: generate tests

* tests: add more tests
  • Loading branch information
vladimirvolek authored Jul 5, 2021
1 parent d6c2212 commit d7dedb6
Show file tree
Hide file tree
Showing 19 changed files with 818 additions and 51 deletions.
1 change: 1 addition & 0 deletions example/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BlockFrostAPI } from '../src/index';

async function run() {
const API = new BlockFrostAPI({
projectId: 'YOUR API KEY HERE', // see: https://blockfrost.io
Expand Down
5 changes: 2 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ module.exports = {
moduleFileExtensions: ['ts', 'js'],
collectCoverage: true,
coveragePathIgnorePatterns: ['/node_modules/'],
setupFiles: ['dotenv/config'],
setupFilesAfterEnv: ['<rootDir>/jest.config.js'],
testMatch: ['<rootDir>/test/unit/tests/**/*.ts'],
testMatch: ['<rootDir>/test/tests/**/*.ts'],
coverageReporters: ['json', 'lcov', 'text', 'text-summary'],
collectCoverageFrom: ['<rootDir>/src/**/*.ts'],
moduleNameMapper: {
'^(types)(.*)$': '<rootDir>/src/types/$2',
'^(utils)(.*)$': '<rootDir>/src/utils/$2',
'^(sql)(.*)$': '<rootDir>/src/sql/$2',
},
setupFilesAfterEnv: ['<rootDir>/test/setup.ts'],
preset: 'ts-jest',
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"generate-types": "pnpify openapi-typescript ./node_modules/@blockfrost/openapi/swagger.yaml --output ./src/types/OpenApi.ts",
"lint": "eslint ./src/**/*.ts",
"run-example": "ts-node-dev --transpile-only ./example/index.ts",
"test": "jest -c jest.config.js"
"test": "jest -c ./jest.config.js"
},
"dependencies": {
"@blockfrost/openapi": "^0.1.22",
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/ledger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getHeaders, handleError } from '../../utils';
import { components } from '../../types/OpenApi';
import { BlockFrostAPI } from '../../index';

export function ledger(
export function genesis(
this: BlockFrostAPI,
): Promise<components['schemas']['genesis_content']> {
return new Promise((resolve, reject) => {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import {
poolsRetiring,
} from './endpoints/pools';

import { ledger } from './endpoints/ledger';
import { genesis } from './endpoints/ledger';
import { root } from './endpoints/root';
import {
metadataTxsLabel,
Expand Down Expand Up @@ -505,7 +505,7 @@ class BlockFrostAPI {
* @returns xxx
*
*/
ledger = ledger;
genesis = genesis;

/**
* metadataTxsLabel
Expand Down
15 changes: 15 additions & 0 deletions test/fixtures/addresses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { SDK } from '../utils';

export default [
{
command: () =>
SDK.addresses(
'addr1q8zu4smzyf2r2mfqjd6tc6vxf2p8rccdfk82ye3eut2udkw9etpkygj5x4kjpym5h35cvj5zw83s6nvw5fnrnck4cmvshkfm4y',
),
response: {
amount: [{ unit: 'lovelace', quantity: expect.any(String) }],
stake_address: expect.toBeTypeOrNull(String),
type: 'shelley',
},
},
] as const;
Loading

0 comments on commit d7dedb6

Please sign in to comment.