resourceSidebar.test.ts 807 B

1234567891011121314151617181920
  1. import { mount } from '@vue/test-utils'
  2. import { describe, expect, it } from 'vitest'
  3. import ResourceSidebar from '@/components/app/ResourceSidebar.vue'
  4. describe('ResourceSidebar', () => {
  5. it('keeps fallback avatars stable across topics from the same team', () => {
  6. const wrapper = mount(ResourceSidebar, {
  7. props: {
  8. items: [
  9. { id: 'topic:room-1:topic-1', title: '话题一', topic: true, avatar: '', avatarFallbackKey: 'room-1' },
  10. { id: 'topic:room-1:topic-2', title: '话题二', topic: true, avatar: '', avatarFallbackKey: 'room-1' },
  11. ],
  12. },
  13. })
  14. const sources = wrapper.findAll<HTMLImageElement>('.team-avatar__image').map(image => image.attributes('src'))
  15. expect(sources).toHaveLength(2)
  16. expect(new Set(sources).size).toBe(1)
  17. })
  18. })