@cosmology/ast
Version:
Cosmos TypeScript AST generation
32 lines • 1.45 kB
JavaScript
import { getNestedProto } from '@cosmology/utils';
import { defaultTelescopeOptions, expectCode, getTestProtoStore } from '../../../test-utils/';
import { AminoParseContext, ProtoParseContext } from '../context';
import { createProtoType } from '..';
import { createObjectWithMethods } from '../object';
import { createAminoConverter, makeAminoTypeInterface } from '../amino/index';
import cases from 'jest-in-case';
const store = getTestProtoStore();
store.traverseAll();
cases('ibc/lightclients/tendermint/v1/tendermint', opts => {
const ref = store.findProto('ibc/lightclients/tendermint/v1/tendermint.proto');
const context = new ProtoParseContext(ref, store, defaultTelescopeOptions);
const aminoCtx = new AminoParseContext(ref, store, defaultTelescopeOptions);
context.options.prototypes.typingsFormat.duration = opts.name;
aminoCtx.options.prototypes.typingsFormat.duration = opts.name;
expectCode(createProtoType(context, 'ClientState', getNestedProto(ref.traversed).ClientState));
expectCode(createObjectWithMethods(context, 'ClientState', getNestedProto(ref.traversed).ClientState));
expectCode(makeAminoTypeInterface({
context: aminoCtx,
proto: getNestedProto(ref.traversed).ClientState
}));
expectCode(createAminoConverter({
context: aminoCtx,
root: ref.proto,
name: 'AminoConverter',
protos: [getNestedProto(ref.traversed).ClientState]
}));
}, [{
name: 'duration'
}, {
name: 'string'
}]);