Skip to content

Commit

Permalink
test: [table] data reactivity issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgoud committed Jan 18, 2024
1 parent 3d6dd10 commit 11bbe85
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/components/table/test/table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,17 @@ describe('Table tests', () => {
expect(wrapper.emitted('sortColumn')).toBeTruthy()
expect(wrapper.emitted('sortColumn')?.[0]?.[0]).toStrictEqual(payload)
})

it('should update the table when items prop changes', async () => {
const headers: PuikTableHeader[] = [{ value: 'firstname' }]
factory({ headers, items: [] })
expect(getRows().length).toBe(0)
const newItems = [{ firstname: 'John' }, { firstname: 'Jane' }]
await wrapper.setProps({ items: newItems })
expect(getRows().length).toBe(newItems.length)
newItems.forEach((item, index) => {
const row = getRows()[index]
expect(row.text()).toContain(item.firstname)
})
})
})

0 comments on commit 11bbe85

Please sign in to comment.