|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright Google LLC All Rights Reserved. |
| 4 | + * |
| 5 | + * Use of this source code is governed by an MIT-style license that can be |
| 6 | + * found in the LICENSE file at https://angular.dev/license |
| 7 | + */ |
| 8 | + |
| 9 | +import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; |
| 10 | +import { Schema as ApplicationOptions } from '../application/schema'; |
| 11 | +import { Schema as WorkspaceOptions } from '../workspace/schema'; |
| 12 | +import { Schema as ConfigOptions, Tool as ConfigTool } from './schema'; |
| 13 | + |
| 14 | +describe('Ai Config Schematic', () => { |
| 15 | + const schematicRunner = new SchematicTestRunner( |
| 16 | + '@schematics/angular', |
| 17 | + require.resolve('../collection.json'), |
| 18 | + ); |
| 19 | + |
| 20 | + const workspaceOptions: WorkspaceOptions = { |
| 21 | + name: 'workspace', |
| 22 | + newProjectRoot: 'projects', |
| 23 | + version: '15.0.0', |
| 24 | + }; |
| 25 | + |
| 26 | + const defaultAppOptions: ApplicationOptions = { |
| 27 | + name: 'foo', |
| 28 | + inlineStyle: true, |
| 29 | + inlineTemplate: true, |
| 30 | + routing: false, |
| 31 | + skipPackageJson: false, |
| 32 | + }; |
| 33 | + |
| 34 | + let applicationTree: UnitTestTree; |
| 35 | + function runConfigSchematic(tool: ConfigTool[]): Promise<UnitTestTree> { |
| 36 | + return schematicRunner.runSchematic<ConfigOptions>('ai-config', { tool }, applicationTree); |
| 37 | + } |
| 38 | + |
| 39 | + beforeEach(async () => { |
| 40 | + const workspaceTree = await schematicRunner.runSchematic('workspace', workspaceOptions); |
| 41 | + applicationTree = await schematicRunner.runSchematic( |
| 42 | + 'application', |
| 43 | + defaultAppOptions, |
| 44 | + workspaceTree, |
| 45 | + ); |
| 46 | + }); |
| 47 | + |
| 48 | + it('should create a GEMINI.MD file', async () => { |
| 49 | + const tree = await runConfigSchematic([ConfigTool.Gemini]); |
| 50 | + tree.exists('.gemini/GEMINI.md'); |
| 51 | + }); |
| 52 | + |
| 53 | + it('should create a copilot-instructions.md file', async () => { |
| 54 | + const tree = await runConfigSchematic([ConfigTool.Copilot]); |
| 55 | + expect(tree.exists('.github/copilot-instructions.md')).toBeTruthy(); |
| 56 | + }); |
| 57 | + |
| 58 | + it('should create a cursor file', async () => { |
| 59 | + const tree = await runConfigSchematic([ConfigTool.Cursor]); |
| 60 | + expect(tree.exists('.cursor/rules/cursor.mdc')).toBeTruthy(); |
| 61 | + }); |
| 62 | + |
| 63 | + it('should create a windsurf file', async () => { |
| 64 | + const tree = await runConfigSchematic([ConfigTool.Windsurf]); |
| 65 | + expect(tree.exists('.windsurf/rules/guidelines.md')).toBeTruthy(); |
| 66 | + }); |
| 67 | + |
| 68 | + it('should create a claude file', async () => { |
| 69 | + const tree = await runConfigSchematic([ConfigTool.Claude]); |
| 70 | + expect(tree.exists('.claude/CLAUDE.md')).toBeTruthy(); |
| 71 | + }); |
| 72 | + |
| 73 | + it('should create a jetbrains file', async () => { |
| 74 | + const tree = await runConfigSchematic([ConfigTool.Jetbrains]); |
| 75 | + expect(tree.exists('.junie/guidelines.md')).toBeTruthy(); |
| 76 | + }); |
| 77 | + |
| 78 | + it('should create multiple files when multiple tools are selected', async () => { |
| 79 | + const tree = await runConfigSchematic([ |
| 80 | + ConfigTool.Gemini, |
| 81 | + ConfigTool.Copilot, |
| 82 | + ConfigTool.Cursor, |
| 83 | + ]); |
| 84 | + expect(tree.exists('.gemini/GEMINI.md')).toBeTruthy(); |
| 85 | + expect(tree.exists('.github/copilot-instructions.md')).toBeTruthy(); |
| 86 | + expect(tree.exists('.cursor/rules/cursor.mdc')).toBeTruthy(); |
| 87 | + }); |
| 88 | +}); |
0 commit comments