Skip to content

Commit

Permalink
Update constructor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnw committed Dec 15, 2023
1 parent 0e3b3d9 commit 76e676a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions js-api-spec/compiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ describe('Compiler', () => {
expect(() => compiler.compileString('$a: b; c {d: $a}')).toThrowError();
});
});

it('errors if constructor invoked directly', () => {
expect(() => new Compiler()).toThrowError(
// Strip types to allow calling private constructor.
class Untyped {}
const UntypedCompiler = Compiler as unknown as typeof Untyped;
expect(() => new UntypedCompiler()).toThrowError(
/Compiler can not be directly constructed/
);
});
Expand Down Expand Up @@ -166,8 +170,12 @@ describe('AsyncCompiler', () => {
await expectAsync(compilation).toBeResolved();
});
});

it('errors if constructor invoked directly', () => {
expect(() => new AsyncCompiler()).toThrowError(
// Strip types to allow calling private constructor.
class Untyped {}
const UntypedAsyncCompiler = AsyncCompiler as unknown as typeof Untyped;
expect(() => new UntypedAsyncCompiler()).toThrowError(
/AsyncCompiler can not be directly constructed/
);
});
Expand Down

0 comments on commit 76e676a

Please sign in to comment.