Skip to content

Commit

Permalink
chore: default-export code improvement
Browse files Browse the repository at this point in the history
chore: refactor defualt exports to named
  • Loading branch information
peter-sanderson committed Oct 21, 2024
1 parent 3dace57 commit f64440f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default [
export const coinselectFixturesErrors = [
{
description: 'missing input info',
feeRate: 10,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default [
export const coinselectIndexFixture = [
{
description: '1 output, no change, 1 input is unspendable coinbase',
feeRate: 10,
Expand Down
2 changes: 1 addition & 1 deletion packages/utxo-lib/tests/__fixtures__/compose.crosscheck.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UTXO } from './compose';

export default [
export const fixturesCrossCheck = [
{
description: '1 input, 1 output, no change',
request: {
Expand Down
2 changes: 1 addition & 1 deletion packages/utxo-lib/tests/__fixtures__/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const UTXO = {
amount: '102001',
};

export default [
export const composeTxFixture = [
{
description: 'builds a simple tx without change',
request: {
Expand Down
8 changes: 4 additions & 4 deletions packages/utxo-lib/tests/coinselect/coinselect.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { coinselect } from '../../src/coinselect';
import fixtures from '../__fixtures__/coinselect/coinselect-index';
import fixturesErrors from '../__fixtures__/coinselect/coinselect-errors';
import { coinselectIndexFixture } from '../__fixtures__/coinselect/coinselect-index';
import { coinselectFixturesErrors } from '../__fixtures__/coinselect/coinselect-errors';
import * as utils from './test.utils';

describe('coinselect errors', () => {
fixturesErrors.forEach(f => {
coinselectFixturesErrors.forEach(f => {
it(f.description, () => {
const inputs = utils.expand(f.inputs, true);
const outputs = utils.expand(f.outputs, false);
Expand All @@ -24,7 +24,7 @@ describe('coinselect errors', () => {
});

describe('coinselect index', () => {
fixtures.forEach(f => {
coinselectIndexFixture.forEach(f => {
it(f.description, () => {
const inputs = utils.expand(f.inputs as any, true);
const outputs = utils.expand(f.outputs as any, false);
Expand Down
9 changes: 5 additions & 4 deletions packages/utxo-lib/tests/compose.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ import { composeTx } from '../src';
import * as NETWORKS from '../src/networks';

import { verifyTxBytes } from './compose.utils';
import fixtures from './__fixtures__/compose';
import fixturesCrossCheck from './__fixtures__/compose.crosscheck';
import { composeTxFixture } from './__fixtures__/compose';
import { fixturesCrossCheck } from './__fixtures__/compose.crosscheck';

// keyof typeof NETWORKS;
const getNetwork = (name?: string) =>
// @ts-expect-error expression of type string can't be used to index type
typeof name === 'string' && NETWORKS[name] ? NETWORKS[name] : NETWORKS.bitcoin;

describe('composeTx', () => {
fixtures.forEach(f => {
describe(composeTx.name, () => {
composeTxFixture.forEach(f => {
const network = getNetwork(f.request.network);
const request = { ...f.request, network };
const result: any = { ...f.result };

it(f.description, () => {
const tx = composeTx(request as any);
expect(tx).toEqual(result);
Expand Down

0 comments on commit f64440f

Please sign in to comment.