mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
test(compiler-cli): add unit tests for output() JIT transform (#54841)
We are already testing the JIT transforms via integration tests, but this commit adds dedicated unit tests for the transform behavior for proper test coverage (planned follow-up). PR Close #54841
This commit is contained in:
parent
c0788200e2
commit
80e5a0a03d
1 changed files with 55 additions and 0 deletions
|
|
@ -375,6 +375,61 @@ describe('initializer API metadata transform', () => {
|
|||
`));
|
||||
});
|
||||
});
|
||||
|
||||
describe('output()', () => {
|
||||
it('should insert an `@Output` decorator', () => {
|
||||
const result = transform(`
|
||||
import {output, Directive} from '@angular/core';
|
||||
|
||||
@Directive({})
|
||||
class MyDir {
|
||||
someInput = output();
|
||||
}
|
||||
`);
|
||||
|
||||
expect(result).toContain(omitLeadingWhitespace(`
|
||||
__decorate([
|
||||
i0.Output("someInput")
|
||||
], MyDir.prototype, "someInput", void 0);
|
||||
`));
|
||||
});
|
||||
|
||||
it('should insert an `@Output` decorator with aliases', () => {
|
||||
const result = transform(`
|
||||
import {output, Directive} from '@angular/core';
|
||||
|
||||
@Directive({})
|
||||
class MyDir {
|
||||
someInput = output({alias: 'someAlias'});
|
||||
}
|
||||
`);
|
||||
|
||||
expect(result).toContain(omitLeadingWhitespace(`
|
||||
__decorate([
|
||||
i0.Output("someAlias")
|
||||
], MyDir.prototype, "someInput", void 0);
|
||||
`));
|
||||
});
|
||||
|
||||
it('should not change an existing `@Output` decorator', () => {
|
||||
const result = transform(`
|
||||
import {output, Output, Directive} from '@angular/core';
|
||||
|
||||
const bla = 'some string';
|
||||
|
||||
@Directive({})
|
||||
class MyDir {
|
||||
@Output(bla) someInput = output({});
|
||||
}
|
||||
`);
|
||||
|
||||
expect(result).toContain(omitLeadingWhitespace(`
|
||||
__decorate([
|
||||
Output(bla)
|
||||
], MyDir.prototype, "someInput", void 0);
|
||||
`));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/** Omits the leading whitespace for each line of the given text. */
|
||||
|
|
|
|||
Loading…
Reference in a new issue