Skip to content

test(reactivity): 100% effectScope coverage#7297

Open
wsypower wants to merge 1 commit intovuejs:mainfrom
wsypower:effectScope-coverage
Open

test(reactivity): 100% effectScope coverage#7297
wsypower wants to merge 1 commit intovuejs:mainfrom
wsypower:effectScope-coverage

Conversation

@wsypower
Copy link
Copy Markdown
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
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
Copy Markdown
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