-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d61efe
commit ae2c9b9
Showing
5 changed files
with
132 additions
and
4 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
projects/client/src/lib/requests/queries/users/listItemsQuery.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,62 @@ | ||
import { assertDefined } from '$lib/utils/assert/assertDefined.ts'; | ||
import { ListedMoviesMappedMock } from '$mocks/data/lists/mapped/ListedMoviesMappedMock.ts'; | ||
import { ListedShowsMappedMock } from '$mocks/data/lists/mapped/ListedShowsMappedMock.ts'; | ||
import { HereticListsMappedMock } from '$mocks/data/summary/movies/heretic/mapped/HereticListsMappedMock.ts'; | ||
import { SiloListsMappedMock } from '$mocks/data/summary/shows/silo/mapped/SiloListsMappedMock.ts'; | ||
import { UserProfileHarryMappedMock } from '$mocks/data/users/mapped/UserProfileHarryMappedMock.ts'; | ||
import { runQuery } from '$test/beds/query/runQuery.ts'; | ||
import { createQuery } from '@tanstack/svelte-query'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { listItemsQuery } from './listItemsQuery.ts'; | ||
|
||
describe('listItemsQuery', () => { | ||
it('should query list items', async () => { | ||
const result = await runQuery({ | ||
factory: () => | ||
createQuery( | ||
listItemsQuery({ | ||
userId: UserProfileHarryMappedMock.slug, | ||
listId: assertDefined(SiloListsMappedMock.at(0)).slug, | ||
}), | ||
), | ||
mapper: (response) => response?.data?.entries, | ||
}); | ||
|
||
expect(result).to.deep.equal([ | ||
...ListedShowsMappedMock, | ||
...ListedMoviesMappedMock, | ||
]); | ||
}); | ||
|
||
it('should query show list items', async () => { | ||
const result = await runQuery({ | ||
factory: () => | ||
createQuery( | ||
listItemsQuery({ | ||
userId: UserProfileHarryMappedMock.slug, | ||
listId: assertDefined(SiloListsMappedMock.at(0)).slug, | ||
type: 'show', | ||
}), | ||
), | ||
mapper: (response) => response?.data?.entries, | ||
}); | ||
|
||
expect(result).to.deep.equal(ListedShowsMappedMock); | ||
}); | ||
|
||
it('should query movie list items', async () => { | ||
const result = await runQuery({ | ||
factory: () => | ||
createQuery( | ||
listItemsQuery({ | ||
userId: UserProfileHarryMappedMock.slug, | ||
listId: assertDefined(HereticListsMappedMock.at(0)).slug, | ||
type: 'movie', | ||
}), | ||
), | ||
mapper: (response) => response?.data?.entries, | ||
}); | ||
|
||
expect(result).to.deep.equal(ListedMoviesMappedMock); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
projects/client/src/lib/requests/queries/users/listSummaryQuery.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,24 @@ | ||
import { assertDefined } from '$lib/utils/assert/assertDefined.ts'; | ||
import { SiloListsMappedMock } from '$mocks/data/summary/shows/silo/mapped/SiloListsMappedMock.ts'; | ||
import { UserProfileHarryMappedMock } from '$mocks/data/users/mapped/UserProfileHarryMappedMock.ts'; | ||
import { runQuery } from '$test/beds/query/runQuery.ts'; | ||
import { createQuery } from '@tanstack/svelte-query'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { listSummaryQuery } from './listSummaryQuery.ts'; | ||
|
||
describe('listSummaryQuery', () => { | ||
it('should query list summary', async () => { | ||
const result = await runQuery({ | ||
factory: () => | ||
createQuery( | ||
listSummaryQuery({ | ||
userId: UserProfileHarryMappedMock.slug, | ||
listId: assertDefined(SiloListsMappedMock.at(0)).slug, | ||
}), | ||
), | ||
mapper: (response) => response?.data, | ||
}); | ||
|
||
expect(result).to.deep.equal(SiloListsMappedMock.at(0)); | ||
}); | ||
}); |
4 changes: 2 additions & 2 deletions
4
projects/client/src/mocks/data/lists/mapped/ListedMoviesMappedMock.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
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
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