-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AF-3082: transform static meta fields #200
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,6 +256,55 @@ main() { | |
reason: 'should preserve existing inheritance'); | ||
}); | ||
|
||
test('with static PropsMeta declaration', () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should also have a test which verifies this functionality on props/state mixins:
|
||
final transformedLine = 'static const PropsMeta meta = \$Props(FooProps);'; | ||
|
||
setUpAndGenerate(''' | ||
@Factory() | ||
UiFactory<FooProps> Foo; | ||
|
||
@Props() | ||
class FooProps { | ||
static const PropsMeta meta = \$metaForFooProps; | ||
} | ||
|
||
@Component() | ||
class FooComponent { | ||
render() => null; | ||
} | ||
''' | ||
); | ||
|
||
var transformedSource = transformedFile.getTransformedText(); | ||
expect(transformedSource, contains(transformedLine)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might make sense to also verify that the original meta line is not longer present to ensure that the transformer is replacing and not simply adding a line. |
||
}); | ||
|
||
test('with static StateMeta declaration', () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can combine the StateMeta and PropsMeta tests into 1 test, since any instance of a component will have at least a props class with a |
||
final transformedLine = 'static const StateMeta meta = \$State(FooState);'; | ||
|
||
setUpAndGenerate(''' | ||
@Factory() | ||
UiFactory<FooProps> Foo; | ||
|
||
@Props() | ||
class FooProps {} | ||
|
||
@State() | ||
class FooState { | ||
static const StateMeta meta = \$metaForFooState; | ||
} | ||
|
||
@Component() | ||
class FooComponent { | ||
render() => null; | ||
} | ||
''' | ||
); | ||
|
||
var transformedSource = transformedFile.getTransformedText(); | ||
expect(transformedSource, contains(transformedLine)); | ||
}); | ||
|
||
group('that subtypes another component, referencing the component class via', () { | ||
test('a simple identifier', () { | ||
preservedLineNumbersTest(''' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we skip lines 417-425? I don't think there should ever be an instance where a
doNotGenerate()
annotation is added to ameta
field