Skip to content

Commit

Permalink
Test compilers throw if constructed
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnw committed Dec 14, 2023
1 parent 0a14b6f commit 0e3b3d9
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions js-api-spec/compiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

import type {AsyncCompiler, Compiler, CompileResult, Importer} from 'sass';
import {initAsyncCompiler, initCompiler, SassString} from 'sass';
import type {CompileResult, Importer} from 'sass';
import {
initAsyncCompiler,
initCompiler,
SassString,
AsyncCompiler,
Compiler,
} from 'sass';

import {spy, URL} from './utils';

Expand Down Expand Up @@ -95,6 +101,11 @@ describe('Compiler', () => {
expect(() => compiler.compileString('$a: b; c {d: $a}')).toThrowError();
});
});
it('errors if constructor invoked directly', () => {
expect(() => new Compiler()).toThrowError(
/Compiler can not be directly constructed/
);
});
});

describe('AsyncCompiler', () => {
Expand Down Expand Up @@ -155,4 +166,9 @@ describe('AsyncCompiler', () => {
await expectAsync(compilation).toBeResolved();
});
});
it('errors if constructor invoked directly', () => {
expect(() => new AsyncCompiler()).toThrowError(
/AsyncCompiler can not be directly constructed/
);
});
});

0 comments on commit 0e3b3d9

Please sign in to comment.