// @vitest-environment jsdom
import { createApp, shallowReactive, ref } from 'vue'

describe('shallowReactive v-for regression', () => {
  test('v-for over shallowReactive array should not unwrap refs', () => {
    const App = {
      setup() {
        const shallowReactiveArray = shallowReactive([
          {
            aaa: ref('aaa1'),
          },
        ])
        return { shallowReactiveArray }
      },
      template: `<span id="a"><template v-for="item in shallowReactiveArray">{{ typeof item.aaa }}</template></span><span id="b">{{ typeof shallowReactiveArray[0].aaa }}</span>`,
    }
    const root = document.createElement('div')
    createApp(App).mount(root)
    const a = root.querySelector('#a')!.textContent
    const b = root.querySelector('#b')!.textContent
    expect(b).toBe('object')
    expect(a).toBe('object')
  })
})
