prettier-plugin-imports
Version:
A prettier plugins to sort imports in provided RegEx order
40 lines (34 loc) • 1.17 kB
text/typescript
import { expect, test } from 'vitest';
import { getExperimentalParserPlugins } from './get-experimental-parser-plugins';
test('it should return empty list', () => {
expect(getExperimentalParserPlugins([])).toEqual([]);
});
test('it should return flow and decorators', () => {
expect(getExperimentalParserPlugins(['flow', 'decorators'])).toEqual([
'flow',
'decorators',
]);
});
test('it should return decorators with parsed options', () => {
expect(
getExperimentalParserPlugins([
'["decorators", { "decoratorsBeforeExport": true }]',
]),
).toEqual([['decorators', { decoratorsBeforeExport: true }]]);
});
test('it should return decorators with parsed options', () => {
expect(
getExperimentalParserPlugins([
'flow',
'["decorators", { "decoratorsBeforeExport": true }]',
]),
).toEqual(['flow', ['decorators', { decoratorsBeforeExport: true }]]);
});
test('it should throw an Error for invalid JSON', () => {
expect(() =>
getExperimentalParserPlugins([
'flow',
'["decorators", { decoratorsBeforeExport: true }]',
]),
).toThrowError('Invalid JSON in importOrderParserPlugins: ');
});