mirror of
https://git.shipoclu.com/moon/plspace.git
synced 2026-08-13 02:42:30 +00:00
pics timeline
This commit is contained in:
@@ -66,4 +66,77 @@ describe('Profile', () => {
|
||||
expect(view.queryByText('Someone else’s note')).not.toBeInTheDocument()
|
||||
expect(view.queryByText('A reply')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('builds Pics from the account’s own image attachments', async () => {
|
||||
const ownPicture = status({
|
||||
id: 'picture-entry',
|
||||
content: '<p>A day at the beach</p>',
|
||||
media_attachments: [
|
||||
{
|
||||
id: 'picture',
|
||||
type: 'image',
|
||||
url: 'https://media.example/beach.jpg',
|
||||
preview_url: 'https://media.example/beach-small.jpg',
|
||||
description: 'Sunset over the beach',
|
||||
},
|
||||
],
|
||||
})
|
||||
const video = status({
|
||||
id: 'video-entry',
|
||||
content: '<p>A video that does not belong in Pics</p>',
|
||||
media_attachments: [
|
||||
{
|
||||
id: 'video',
|
||||
type: 'video',
|
||||
url: 'https://media.example/movie.mp4',
|
||||
preview_url: 'https://media.example/movie.jpg',
|
||||
description: 'A movie',
|
||||
},
|
||||
],
|
||||
})
|
||||
const repostedPicture = status({
|
||||
id: 'repost',
|
||||
reblog: status({
|
||||
id: 'someone-elses-picture',
|
||||
content: '<p>Someone else’s picture</p>',
|
||||
media_attachments: [
|
||||
{
|
||||
id: 'reposted-picture',
|
||||
type: 'image',
|
||||
url: 'https://media.example/reposted.jpg',
|
||||
preview_url: null,
|
||||
description: 'A reposted picture',
|
||||
},
|
||||
],
|
||||
}),
|
||||
})
|
||||
const fetchAccountStatuses = vi.fn().mockResolvedValue({
|
||||
items: [ownPicture, video, repostedPicture],
|
||||
links: {},
|
||||
})
|
||||
const services = testServices({
|
||||
session: session(),
|
||||
theme: theme(),
|
||||
endpoints: {
|
||||
lookupAccount: vi.fn().mockResolvedValue(account()),
|
||||
fetchAccountStatuses,
|
||||
},
|
||||
})
|
||||
const view = render(Profile, {
|
||||
props: { acct: 'alice', view: 'pics' },
|
||||
context: new Map([[APP_SERVICES, services]]),
|
||||
})
|
||||
|
||||
expect(await view.findByRole('img', { name: 'Sunset over the beach' })).toHaveAttribute(
|
||||
'src',
|
||||
'https://media.example/beach-small.jpg',
|
||||
)
|
||||
expect(fetchAccountStatuses.mock.calls[0][3]).toEqual({
|
||||
only_media: true,
|
||||
exclude_reblogs: true,
|
||||
})
|
||||
expect(view.getByText('Sunset over the beach')).toBeInTheDocument()
|
||||
expect(view.queryByText('A movie')).not.toBeInTheDocument()
|
||||
expect(view.queryByText('A reposted picture')).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user