Skip to content

Commit

Permalink
remove some more redundant asyncs
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainMuller committed Apr 1, 2022
1 parent 10db505 commit 39bcb7e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions packages/jsii-reflect/test/independent.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as reflect from '../lib';
import { assemblyFromSource } from './util';

test('get full github source location for a class or method', async () => {
test('get full github source location for a class or method', () => {
// WHEN
const assembly = await assemblyFromSource(
const assembly = assemblyFromSource(
`
export class Foo {
public bar() {
Expand Down
36 changes: 18 additions & 18 deletions packages/jsii-reflect/test/type-system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { typeSystemFromSource, assemblyFromSource } from './util';

let typesys: TypeSystem;

beforeAll(async () => {
beforeAll(() => {
typesys = new TypeSystem();
await typesys.loadModule(resolveModuleDir('jsii-calc'));
});
Expand All @@ -34,7 +34,7 @@ test('findClass', () => {
expect(actual.join('\n')).toMatchSnapshot();
});

test('"roots" is a list of the directly loaded assemblies', async () => {
test('"roots" is a list of the directly loaded assemblies', () => {
expect(typesys.roots.length).toBe(1);
expect(typesys.roots[0]).toBe(typesys.findAssembly('jsii-calc'));

Expand Down Expand Up @@ -203,8 +203,8 @@ test('Submodules can have a README', () => {
);
});

test('overridden member knows about both parent types', async () => {
const ts = await typeSystemFromSource(`
test('overridden member knows about both parent types', () => {
const ts = typeSystemFromSource(`
export class Foo {
public bar() {
Array.isArray(3);
Expand Down Expand Up @@ -256,8 +256,8 @@ describe('Stability', () => {
// ----------------------------------------------------------------------

describe('lowest stability guarantee is advertised', () => {
test('when subclass is experimental', async () => {
const ts = await typeSystemFromSource(`
test('when subclass is experimental', () => {
const ts = typeSystemFromSource(`
/**
* @stable
*/
Expand Down Expand Up @@ -285,8 +285,8 @@ describe('Stability', () => {
expect(method.docs.stability).toEqual(Stability.Experimental);
});

test('when method is experimental', async () => {
const ts = await typeSystemFromSource(`
test('when method is experimental', () => {
const ts = typeSystemFromSource(`
/**
* @stable
*/
Expand Down Expand Up @@ -321,8 +321,8 @@ describe('Stability', () => {
expect(method.docs.stability).toEqual(Stability.Experimental);
});

test('when method is explicitly marked stable', async () => {
const ts = await typeSystemFromSource(`
test('when method is explicitly marked stable', () => {
const ts = typeSystemFromSource(`
/**
* @stable
*/
Expand Down Expand Up @@ -357,8 +357,8 @@ describe('Stability', () => {
expect(method.docs.stability).toEqual(Stability.Experimental);
});

test('external stability', async () => {
const ts = await typeSystemFromSource(`
test('external stability', () => {
const ts = typeSystemFromSource(`
/**
* @stability external
*/
Expand All @@ -383,8 +383,8 @@ describe('Stability', () => {
});
});

test('TypeSystem.properties', async () => {
const ts = await typeSystemFromSource(`
test('TypeSystem.properties', () => {
const ts = typeSystemFromSource(`
export namespace submodule {
export class Foo {
public readonly test = 'TEST';
Expand All @@ -397,8 +397,8 @@ test('TypeSystem.properties', async () => {
expect(ts.properties).toHaveLength(2);
});

test('TypeSystem.methods', async () => {
const ts = await typeSystemFromSource(`
test('TypeSystem.methods', () => {
const ts = typeSystemFromSource(`
export namespace submodule {
export class Foo {
public method(): void {}
Expand All @@ -411,8 +411,8 @@ test('TypeSystem.methods', async () => {
expect(ts.methods).toHaveLength(2);
});

test('Assembly allTypes includes submodule types', async () => {
const asm = await assemblyFromSource({
test('Assembly allTypes includes submodule types', () => {
const asm = assemblyFromSource({
'index.ts': 'export * as submod from "./submod";',
'submod.ts': `export class Foo {}`,
});
Expand Down
10 changes: 5 additions & 5 deletions packages/jsii-reflect/test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { sourceToAssemblyHelper, MultipleSourceFiles, PackageInfo } from 'jsii';

import { Assembly, TypeSystem } from '../lib';

export async function typeSystemFromSource(
export function typeSystemFromSource(
source: string | MultipleSourceFiles,
cb?: (obj: PackageInfo) => void,
) {
const asm = await assemblyFromSource(source, cb);
const asm = assemblyFromSource(source, cb);
return asm.system;
}

export async function assemblyFromSource(
export function assemblyFromSource(
source: string | MultipleSourceFiles,
cb?: (obj: PackageInfo) => void,
): Promise<Assembly> {
const ass = await sourceToAssemblyHelper(source, cb);
): Assembly {
const ass = sourceToAssemblyHelper(source, cb);
const ts = new TypeSystem();
return ts.addAssembly(new Assembly(ts, ass));
}

0 comments on commit 39bcb7e

Please sign in to comment.