Skip to content

Commit

Permalink
test(material/schematics): Add test for CSS token renames
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed May 9, 2024
1 parent 1756f13 commit 8852a09
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/material/schematics/ng-update/test-cases/v18-renames.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {createTestCaseSetup} from '@angular/cdk/schematics/testing';
import {MIGRATION_PATH} from '../../paths';

describe('V18 token renames', () => {
async function setup(originalSource: string): Promise<string> {
const themePath = 'projects/cdk-testing/theme.scss';
const {runFixers, writeFile, appTree} = await createTestCaseSetup(
'migration-v18',
MIGRATION_PATH,
[],
);

writeFile(themePath, originalSource);
await runFixers();
return appTree.readContent(themePath);
}

it('should migrate mdc-form-field tokens', async () => {
const result = await setup(
[
`body {`,
` --mdc-form-field-label-text-color: red;`,
` --mdc-form-field-label-text-font: Roboto;`,
` --mdc-form-field-label-text-size: 16px;`,
` --mdc-form-field-label-text-weight: bold;`,
` --mdc-form-field-label-text-tracking: 0;`,
` --mdc-form-field-label-text-line-height: 1.2;`,
` --mdc-form-field-label-text-color-custom: green;`,
`}`,
].join('\n'),
);

expect(result.split('\n')).toEqual([
`body {`,
` --mat-checkbox-label-text-color: red;`,
` --mat-checkbox-label-text-font: Roboto;`,
` --mat-checkbox-label-text-size: 16px;`,
` --mat-checkbox-label-text-weight: bold;`,
` --mat-checkbox-label-text-tracking: 0;`,
` --mat-checkbox-label-text-line-height: 1.2;`,
` --mdc-form-field-label-text-color-custom: green;`,
`}`,
]);
});

it('should migrate token reads', async () => {});
});

0 comments on commit 8852a09

Please sign in to comment.