Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-leong committed Sep 9, 2024
1 parent 4effc9d commit 5015687
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/runtime-core/__tests__/helpers/renderList.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { reactive, ref, shallowReactive } from '../../src/index'
import { renderList } from '../../src/helpers/renderList'

describe('renderList', () => {
Expand Down Expand Up @@ -56,4 +57,17 @@ describe('renderList', () => {
renderList(undefined, (item, index) => `node ${index}: ${item}`),
).toEqual([])
})

it('should render items in a reactive array correctly', () => {
const reactiveArray = reactive([{ foo: ref('foo') }])
const shallowReactiveArray = shallowReactive([{ foo: ref('foo') }])

expect(renderList(reactiveArray, item => `${typeof item.foo}`)).toEqual([
'string',
])

expect(
renderList(shallowReactiveArray, item => `${typeof item.foo}`),
).toEqual(['object'])
})
})

0 comments on commit 5015687

Please sign in to comment.