@nx/gatsby
Version:
Gatsby Plugin for Nx
51 lines (44 loc) • 1.5 kB
text/typescript
import { Tree } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { applicationGenerator } from '../application/application';
import { componentGenerator } from './component';
xdescribe('component', () => {
let tree: Tree;
let projectName: string;
beforeEach(async () => {
projectName = 'my-app';
tree = createTreeWithEmptyWorkspace();
tree.write('.gitignore', '# empty');
tree.write('.prettierignore', '# empty');
await applicationGenerator(tree, {
name: projectName,
style: 'css',
standaloneConfig: false,
});
});
it('should generate component in components directory', async () => {
await componentGenerator(tree, {
name: 'hello',
project: projectName,
style: 'css',
});
expect(tree.exists('apps/my-app/src/components/hello.tsx')).toBeTruthy();
expect(
tree.exists('apps/my-app/src/components/hello.spec.tsx')
).toBeTruthy();
expect(
tree.exists('apps/my-app/src/components/hello.module.css')
).toBeTruthy();
});
it('should allow directory override', async () => {
await componentGenerator(tree, {
name: 'hello',
project: projectName,
directory: 'lib',
style: 'css',
});
expect(tree.exists('apps/my-app/src/lib/hello.tsx')).toBeTruthy();
expect(tree.exists('apps/my-app/src/lib/hello.spec.tsx')).toBeTruthy();
expect(tree.exists('apps/my-app/src/lib/hello.module.css')).toBeTruthy();
});
});