nx/packages/vue/src/generators/application/application.spec.ts
Jason Jean 396ffc4636
feat(core): enable project crystal by default (#21403)
Co-authored-by: Katerina Skroumpelou <sk.katherine@gmail.com>
Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
Co-authored-by: Colum Ferry <cferry09@gmail.com>
Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
Co-authored-by: Emily Xiong <xiongemi@gmail.com>
Co-authored-by: Nicholas Cunningham <ndcunningham@gmail.com>
2024-02-02 03:40:59 -05:00

48 lines
1.6 KiB
TypeScript

import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { Tree, readProjectConfiguration } from '@nx/devkit';
import { applicationGenerator } from './application';
import { Schema } from './schema';
describe('application generator', () => {
let tree: Tree;
const options: Schema = { name: 'test' } as Schema;
beforeEach(() => {
tree = createTreeWithEmptyWorkspace();
});
it('should run successfully', async () => {
await applicationGenerator(tree, options);
const config = readProjectConfiguration(tree, 'test');
expect(config).toBeDefined();
});
it('should set up project correctly with given options', async () => {
await applicationGenerator(tree, { ...options, unitTestRunner: 'vitest' });
expect(tree.read('.eslintrc.json', 'utf-8')).toMatchSnapshot();
expect(tree.read('test/vite.config.ts', 'utf-8')).toMatchSnapshot();
expect(tree.read('test/.eslintrc.json', 'utf-8')).toMatchSnapshot();
expect(tree.read('test/src/app/App.spec.ts', 'utf-8')).toMatchSnapshot();
expect(listFiles(tree)).toMatchSnapshot();
});
it('should not use stylesheet if --style=none', async () => {
await applicationGenerator(tree, { ...options, style: 'none' });
expect(tree.exists('test/src/style.none')).toBeFalsy();
expect(tree.read('test/src/main.ts', 'utf-8')).not.toContain('styles.none');
});
});
function listFiles(tree: Tree): string[] {
const files = new Set<string>();
tree.listChanges().forEach((change) => {
if (change.type !== 'DELETE') {
files.add(change.path);
}
});
return Array.from(files).sort((a, b) => a.localeCompare(b));
}