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): support passing object with only one get property #9122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/reactivity/__tests__/computed.spec.ts
Original file line number Diff line number Diff line change
@@ -151,6 +151,14 @@ describe('reactivity/computed', () => {
expect(n.value).toBe(-1)
})

it('should support passing object with only one get property', () => {
const a = computed(() => 1)
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 the scenario tested by a is already tested by it('should be readonly'. I think that part can be removed here.

I also wonder whether the test for b should just be merged into it('should be readonly'? Or, if not, maybe move this test case to be next to that one?

// @ts-expect-error
const b = computed({ get: () => 1 })
expect(isReadonly(a)).toBe(true)
expect(isReadonly(b)).toBe(true)
})

it('should trigger effect w/ setter', () => {
const n = ref(1)
const plusOne = computed({