-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
fix(web): recent albums sort (#14545)
1 parent
e2b3647
commit 5e955a1
Showing
2 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
web/src/lib/components/shared-components/side-bar/recent-albums.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { sdkMock } from '$lib/__mocks__/sdk.mock'; | ||
import RecentAlbums from '$lib/components/shared-components/side-bar/recent-albums.svelte'; | ||
import { albumFactory } from '@test-data/factories/album-factory'; | ||
import { render, screen } from '@testing-library/svelte'; | ||
import { tick } from 'svelte'; | ||
|
||
describe('RecentAlbums component', () => { | ||
it('sorts albums by most recently updated', async () => { | ||
const albums = [ | ||
albumFactory.build({ updatedAt: '2024-01-01T00:00:00Z' }), | ||
albumFactory.build({ updatedAt: '2024-01-09T00:00:01Z' }), | ||
albumFactory.build({ updatedAt: '2024-01-10T00:00:00Z' }), | ||
albumFactory.build({ updatedAt: '2024-01-09T00:00:00Z' }), | ||
]; | ||
|
||
sdkMock.getAllAlbums.mockResolvedValueOnce([...albums]); | ||
render(RecentAlbums); | ||
|
||
expect(sdkMock.getAllAlbums).toBeCalledTimes(1); | ||
await tick(); | ||
|
||
const links = screen.getAllByRole('link'); | ||
expect(links).toHaveLength(3); | ||
expect(links[0]).toHaveAttribute('href', `/albums/${albums[2].id}`); | ||
expect(links[1]).toHaveAttribute('href', `/albums/${albums[1].id}`); | ||
expect(links[2]).toHaveAttribute('href', `/albums/${albums[3].id}`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters