a477b007e1
* Squashed clients/validator content from old branch * fix up tests fix up linting * add bundle script * add build prod script to package json update tests * update readme + copy to dist output update global types update types and tests! * update package build * move types and tests into src * Squashed clients/validator content from old branch fix up tests fix up linting * add bundle script * add build prod script to package json update tests * update readme + copy to dist output update global types update types and tests! update package build * move types and tests into src * build to sub-dir * Fixing the few broken tests --------- Co-authored-by: Jon Häggblad <jon.haggblad@gmail.com> Co-authored-by: benedettadavico <benedetta.davico@gmail.com>
20 lines
697 B
TypeScript
20 lines
697 B
TypeScript
import { Mock, Times } from 'moq.ts';
|
|
import expect from 'expect';
|
|
import { INyxdQuery } from '../../query-client';
|
|
|
|
export class TestHelper {
|
|
buildMethod = async <T>(methodName: string, args: any[], expectedResult: any): Promise<T> => {
|
|
const client = new Mock<INyxdQuery>()
|
|
.setup((nym) => nym[methodName](...args))
|
|
.returns(Promise.resolve(expectedResult));
|
|
const obj = client.object();
|
|
const actualDetails = await obj[methodName](...args);
|
|
|
|
client.verify((nym) => nym[methodName](...args), Times.Exactly(1));
|
|
expect(Object.keys([actualDetails])).toEqual(Object.keys(expectedResult));
|
|
expect(actualDetails).toBeDefined();
|
|
|
|
return actualDetails;
|
|
};
|
|
}
|