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

test(reactivity): 100% effectScope coverage #7297

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wsypower
Copy link
Contributor

@wsypower wsypower commented Dec 8, 2022

test(reactivity): 100% effectScope coverage

test(reactivity): 100%  effectScope coverage
@pikax pikax added the 🧹 p1-chore Priority 1: this doesn't change code behavior. label Oct 20, 2023
@@ -222,7 +222,7 @@ describe('reactivity/effect/scope', () => {

it('should dereference child scope from parent scope after stopping child scope (no memleaks)', () => {
const parent = new EffectScope()
const child = parent.run(() => new EffectScope())!
const [child] = parent.run(() => [new EffectScope(), new EffectScope()])!
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd be better to add a new test for this, rather than modifying the existing test.

In effectScope.ts, there's this if check:

if (last && last !== this) {

That line is only hit once by the tests. Currently it evaluates to false. The change proposed here would switch that, so it evaluates to true. That increases the line coverage, but it's still only testing one of the two branches of the if. Either way there's a chunk of code that could be removed and the tests would still pass.

For example, imagine that if check were changed to this:

if (last) {

That would be incorrect and the existing test would catch that, but the new test would still pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧹 p1-chore Priority 1: this doesn't change code behavior. wait changes
Projects
Status: Needs Review
Development

Successfully merging this pull request may close these issues.

4 participants