-
Is it possible to test a component with an Assuming we have // Component
class Example {
constructor(@Attribute("test") public readonly test: string) {}
} I would assume that this would be set the same as any other // Tests
beforeEach(() => MockBuilder(Example, Module));
it('test', () => expect(MockRender(Example, { test: "test" }).point.componentInstance.test).toEqual("test");) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Relevant angular docs https://angular.io/api/core/Attribute |
Beta Was this translation helpful? Give feedback.
-
Hi, as I see, I would suggest to pass a template instead of the class: it('test', () => {
const { point } = MockRender<Example>('<example test="test"></example>');
expect(point.componentInstance.test).toEqual('test');
}); |
Beta Was this translation helpful? Give feedback.
Hi,
as I see,
@Attribute
is static, it means<input type="text">
injectstext
, whereas<input type="{{ type }}">
or<input [type]="type">
injectnull
.I would suggest to pass a template instead of the class: