github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/js/src/solts/lib/syntax.test.ts (about) 1 import assert from 'assert'; 2 import { factory, Node } from 'typescript'; 3 import { printNodes } from '../api'; 4 import { createCallbackType, createParameter, createPromiseOf, PromiseType, StringType } from './syntax'; 5 6 describe('syntax helpers', function () { 7 it('should create callback expression', async function () { 8 const ErrAndResult = [ 9 createParameter(factory.createIdentifier('err'), undefined), 10 createParameter(factory.createIdentifier('result'), undefined), 11 ]; 12 assertGenerates(createCallbackType(ErrAndResult), '(err, result) => void'); 13 }); 14 15 it('should create promise type', () => { 16 assertGenerates(factory.createExpressionWithTypeArguments(PromiseType, [StringType]), 'Promise<string>'); 17 assertGenerates(createPromiseOf(StringType), 'Promise<string>'); 18 }); 19 }); 20 21 function assertGenerates(node: Node, expected: string) { 22 assert.strictEqual(printNodes(node), expected); 23 }