Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cdk/schematics/utils/project-targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export function getProjectBuildTargets(
project,
builder =>
builder === '@angular-devkit/build-angular:application' ||
builder === '@angular-devkit/build-angular:browser',
builder === '@angular-devkit/build-angular:browser' ||
builder === '@angular-devkit/build-angular:browser-esbuild',
);
}

Expand Down
69 changes: 69 additions & 0 deletions src/material/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,75 @@ describe('ng-add schematic', () => {
.toContain('BrowserAnimationsModule');
});
});

describe('using browser-esbuild builder', () => {
beforeEach(() => {
const config = {
version: 1,
projects: {
material: {
projectType: 'application',
root: 'projects/material',
sourceRoot: 'projects/material/src',
prefix: 'app',
architect: {
build: {
builder: '@angular-devkit/build-angular:browser-esbuild',
options: {
outputPath: 'dist/material',
index: 'projects/material/src/index.html',
main: 'projects/material/src/main.ts',
styles: ['projects/material/src/styles.css'],
},
},
test: {
builder: '@angular-devkit/build-angular:karma',
options: {
outputPath: 'dist/material',
index: 'projects/material/src/index.html',
browser: 'projects/material/src/main.ts',
styles: ['projects/material/src/styles.css'],
},
},
},
},
},
};

appTree.overwrite('/angular.json', JSON.stringify(config, null, 2));
});

it('should add a theme', async () => {
const tree = await runner.runSchematic('ng-add-setup-project', baseOptions, appTree);
const workspace = await getWorkspace(tree);
const project = getProjectFromWorkspace(workspace, baseOptions.project);

expectProjectStyleFile(project, '@angular/material/prebuilt-themes/indigo-pink.css');
});

it('should add material app styles', async () => {
const tree = await runner.runSchematic('ng-add-setup-project', baseOptions, appTree);
const workspace = await getWorkspace(tree);
const project = getProjectFromWorkspace(workspace, baseOptions.project);

const defaultStylesPath = getProjectStyleFile(project)!;
const htmlContent = tree.read(defaultStylesPath)!.toString();

expect(htmlContent).toContain('html, body { height: 100%; }');
expect(htmlContent).toContain(
'body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }',
);
});

it('should add the BrowserAnimationsModule to the project module', async () => {
const tree = await runner.runSchematic('ng-add-setup-project', baseOptions, appTree);
const fileContent = getFileContent(tree, '/projects/material/src/app/app.module.ts');

expect(fileContent)
.withContext('Expected the project app module to import the "BrowserAnimationsModule".')
.toContain('BrowserAnimationsModule');
});
});
});

describe('ng-add schematic - library project', () => {
Expand Down