Skip to content
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

Add mavericks VM factory function to the list of VM factories #92

Merged
merged 1 commit into from Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -108,7 +108,8 @@ class ComposeViewModelInjection : ComposeKtVisitor {
"viewModel", // AAC VM
"weaverViewModel", // Weaver
"hiltViewModel", // Hilt
"injectedViewModel" // Whetstone
"injectedViewModel", // Whetstone
"mavericksViewModel" // Mavericks
)
}

Expand Down
Expand Up @@ -16,7 +16,7 @@ class ComposeViewModelInjectionCheckTest {
private val rule = ComposeViewModelInjectionCheck(Config.empty)

@ParameterizedTest
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel"])
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel", "injectedViewModel", "mavericksViewModel"])
fun `passes when a weaverViewModel is used as a default param`(viewModel: String) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can probably make use
val vmNames = arrayOf("viewModel", "weaverViewModel", "hiltViewModel", "injectedViewModel", "mavericksViewModel")
if you want to avoid some of this boilerplate in all the tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea this is getting old pretty fast

@Language("kotlin")
val code =
Expand All @@ -33,7 +33,7 @@ class ComposeViewModelInjectionCheckTest {
}

@ParameterizedTest
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel"])
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel", "injectedViewModel", "mavericksViewModel"])
fun `overridden functions are ignored`(viewModel: String) {
@Language("kotlin")
val code =
Expand All @@ -48,7 +48,7 @@ class ComposeViewModelInjectionCheckTest {
}

@ParameterizedTest
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel"])
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel", "injectedViewModel", "mavericksViewModel"])
fun `errors when a weaverViewModel is used at the beginning of a Composable`(viewModel: String) {
@Language("kotlin")
val code =
Expand Down Expand Up @@ -79,7 +79,7 @@ class ComposeViewModelInjectionCheckTest {
}

@ParameterizedTest
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel"])
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel", "injectedViewModel", "mavericksViewModel"])
fun `errors when a weaverViewModel is used in different branches`(viewModel: String) {
@Language("kotlin")
val code =
Expand Down
Expand Up @@ -14,7 +14,7 @@ class ComposeViewModelInjectionCheckTest {
private val injectionRuleAssertThat = assertThatRule { ComposeViewModelInjectionCheck() }

@ParameterizedTest
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel"])
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel", "injectedViewModel", "mavericksViewModel"])
fun `passes when a weaverViewModel is used as a default param`(viewModel: String) {
@Language("kotlin")
val code =
Expand All @@ -30,7 +30,7 @@ class ComposeViewModelInjectionCheckTest {
}

@ParameterizedTest
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel"])
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel", "injectedViewModel", "mavericksViewModel"])
fun `overridden functions are ignored`(viewModel: String) {
@Language("kotlin")
val code =
Expand All @@ -44,7 +44,7 @@ class ComposeViewModelInjectionCheckTest {
}

@ParameterizedTest
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel"])
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel", "injectedViewModel", "mavericksViewModel"])
fun `errors when a weaverViewModel is used at the beginning of a Composable`(viewModel: String) {
@Language("kotlin")
val code =
Expand Down Expand Up @@ -82,7 +82,7 @@ class ComposeViewModelInjectionCheckTest {
}

@ParameterizedTest
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel"])
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel", "injectedViewModel", "mavericksViewModel"])
fun `errors when a weaverViewModel is used in different branches`(viewModel: String) {
@Language("kotlin")
val code =
Expand Down Expand Up @@ -111,7 +111,7 @@ class ComposeViewModelInjectionCheckTest {
}

@ParameterizedTest
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel"])
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel", "injectedViewModel", "mavericksViewModel"])
fun `fix no args composable function adds the code inside the parentheses`(viewModel: String) {
@Language("kotlin")
val badCode = """
Expand Down Expand Up @@ -139,7 +139,7 @@ class ComposeViewModelInjectionCheckTest {
}

@ParameterizedTest
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel"])
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel", "injectedViewModel", "mavericksViewModel"])
fun `fix normal args composable function adds the new code at the end`(viewModel: String) {
@Language("kotlin")
val badCode = """
Expand All @@ -166,7 +166,7 @@ class ComposeViewModelInjectionCheckTest {
}

@ParameterizedTest
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel"])
@ValueSource(strings = ["viewModel", "weaverViewModel", "hiltViewModel", "injectedViewModel", "mavericksViewModel"])
fun `fix trailing lambda args composable function adds the new code before the trailing lambda`(viewModel: String) {
@Language("kotlin")
val badCode = """
Expand Down