mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-23 15:36:23 +08:00
This commit enabled users to opt-in adding SSR and SSG to their application during the `ng new` experience. This can be done either by using the `--ssr` option or answer `Yes` when prompted.
62 lines
1.5 KiB
TypeScript
62 lines
1.5 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
|
|
|
|
import { join } from 'node:path';
|
|
|
|
describe('@angular/ssr ng-add schematic', () => {
|
|
const defaultOptions = {
|
|
project: 'test-app',
|
|
};
|
|
|
|
const schematicRunner = new SchematicTestRunner(
|
|
'@angular/ssr',
|
|
require.resolve(join(__dirname, '../collection.json')),
|
|
);
|
|
|
|
let appTree: UnitTestTree;
|
|
|
|
const workspaceOptions = {
|
|
name: 'workspace',
|
|
newProjectRoot: 'projects',
|
|
version: '6.0.0',
|
|
};
|
|
|
|
beforeEach(async () => {
|
|
appTree = await schematicRunner.runExternalSchematic(
|
|
'@schematics/angular',
|
|
'workspace',
|
|
workspaceOptions,
|
|
);
|
|
appTree = await schematicRunner.runExternalSchematic(
|
|
'@schematics/angular',
|
|
'application',
|
|
{
|
|
name: 'test-app',
|
|
inlineStyle: false,
|
|
inlineTemplate: false,
|
|
routing: false,
|
|
style: 'css',
|
|
skipTests: false,
|
|
standalone: true,
|
|
},
|
|
appTree,
|
|
);
|
|
});
|
|
|
|
it('works', async () => {
|
|
const filePath = '/projects/test-app/server.ts';
|
|
|
|
expect(appTree.exists(filePath)).toBeFalse();
|
|
const tree = await schematicRunner.runSchematic('ng-add', defaultOptions, appTree);
|
|
expect(tree.exists(filePath)).toBeTrue();
|
|
});
|
|
});
|