57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { readJson, Tree } from '@nx/devkit';
|
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
import { Linter } from '@nx/linter';
|
|
import { libraryGenerator } from '../../generators/library/library';
|
|
import { removeStyledJsxBabelConfig } from './remove-styled-jsx-babel-plugin';
|
|
|
|
describe('Remove styled-jsx babel plugin for Next libs', () => {
|
|
let tree: Tree;
|
|
|
|
beforeEach(async () => {
|
|
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
|
|
await libraryGenerator(tree, {
|
|
name: 'test-lib',
|
|
style: 'styled-jsx',
|
|
skipFormat: false,
|
|
skipTsConfig: false,
|
|
linter: Linter.EsLint,
|
|
unitTestRunner: 'jest',
|
|
});
|
|
});
|
|
|
|
it('should remove styled-jsx babel plugin', async () => {
|
|
tree.write(
|
|
'libs/test-lib/.babelrc',
|
|
JSON.stringify({
|
|
presets: ['next/babel'],
|
|
plugins: ['styled-jsx/babel'],
|
|
})
|
|
);
|
|
|
|
await removeStyledJsxBabelConfig(tree);
|
|
const result = readJson(tree, 'libs/test-lib/.babelrc');
|
|
expect(result.plugins).toEqual([]);
|
|
});
|
|
it('should remove styled-jsx babel plugin but leave potentially other plugins in there', async () => {
|
|
tree.write(
|
|
'libs/test-lib/.babelrc',
|
|
JSON.stringify({
|
|
presets: ['next/babel'],
|
|
plugins: [
|
|
'some-other/plugin',
|
|
'styled-jsx/babel',
|
|
'some-storybook/plugin',
|
|
],
|
|
})
|
|
);
|
|
|
|
await removeStyledJsxBabelConfig(tree);
|
|
const result = readJson(tree, 'libs/test-lib/.babelrc');
|
|
expect(result.plugins).toEqual([
|
|
'some-other/plugin',
|
|
'some-storybook/plugin',
|
|
]);
|
|
});
|
|
});
|