Skip to content

Commit

Permalink
chore(schematics): replace template line endings with platform specific
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Dec 25, 2024
1 parent 693ef90 commit 87bcadd
Showing 1 changed file with 10 additions and 27 deletions.
37 changes: 10 additions & 27 deletions projects/cdk/schematics/ng-update/v4/tests/replace-crlf.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,17 @@ import {createAngularJson} from '../../../utils/create-angular-json';

const collectionPath = join(__dirname, '../../../migration.json');

const COMPONENT_BEFORE = `\r\n
@Component({
const COMPONENT_BEFORE = `\r\n@Component({
standalone: true,
templateUrl: './test.template.html',
template: '',
})
export class Test {}\r\n`;
export class Test {}`;

const COMPONENT_AFTER = `${EOL}
@Component({
const COMPONENT_AFTER = `${EOL}@Component({
standalone: true,
templateUrl: './test.template.html',
template: '',
})
export class Test {}${EOL}`;

const TEMPLATE_BEFORE = '\r\n<p>Hello</p>\r\n';

const TEMPLATE_AFTER = `${EOL}<p>Hello</p>${EOL}`;

const PACKAGE_BEFORE =
'{"dependencies": {"@angular/core": "~13.0.0", "@taiga-ui/addon-commerce": "~3.42.0"}}\r\n';

const PACKAGE_AFTER = `{
"dependencies": {
"@angular/core": "~13.0.0",
"@taiga-ui/addon-commerce": "~3.42.0",
"@taiga-ui/event-plugins": "^4.2.3"
}
}${EOL}`;
export class Test {}`;

describe('ng-update', () => {
let host: UnitTestTree;
Expand All @@ -67,9 +50,7 @@ describe('ng-update', () => {
host,
);

expect(tree.readContent('test/app/test.template.html')).toEqual(TEMPLATE_AFTER);
expect(tree.readContent('test/app/test.component.ts')).toEqual(COMPONENT_AFTER);
expect(tree.readContent('package.json')).toEqual(PACKAGE_AFTER);
});

afterEach(() => {
Expand All @@ -80,6 +61,8 @@ describe('ng-update', () => {
function createMainFiles(): void {
createAngularJson();
createSourceFile('test/app/test.component.ts', COMPONENT_BEFORE);
createSourceFile('test/app/test.template.html', TEMPLATE_BEFORE);
createSourceFile('package.json', PACKAGE_BEFORE);
createSourceFile(
'package.json',
'{"dependencies": {"@angular/core": "~13.0.0", "@taiga-ui/addon-commerce": "~3.42.0"}}',
);
}

0 comments on commit 87bcadd

Please sign in to comment.