-
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.
test(requests): requesting listed movies and shows
- Loading branch information
1 parent
0398a08
commit 0cd3ec4
Showing
8 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
projects/client/src/lib/requests/queries/lists/listMovieItemsQuery.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,16 @@ | ||
import { ListedMoviesMappedMock } from '$mocks/data/lists/mapped/ListedMoviesMappedMock.ts'; | ||
import { runQuery } from '$test/beds/query/runQuery.ts'; | ||
import { createQuery } from '@tanstack/svelte-query'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { listMovieItemsQuery } from './listMovieItemsQuery.ts'; | ||
|
||
describe('listMovieItemsQuery', () => { | ||
it('should query for movies on a list', async () => { | ||
const result = await runQuery({ | ||
factory: () => createQuery(listMovieItemsQuery({ id: 1 })), | ||
mapper: (response) => response?.data, | ||
}); | ||
|
||
expect(result).to.deep.equal(ListedMoviesMappedMock); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
projects/client/src/lib/requests/queries/lists/listShowItemsQuery.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,16 @@ | ||
import { ListedShowsMappedMock } from '$mocks/data/lists/mapped/ListedShowsMappedMock.ts'; | ||
import { runQuery } from '$test/beds/query/runQuery.ts'; | ||
import { createQuery } from '@tanstack/svelte-query'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { listShowItemsQuery } from './listShowItemsQuery.ts'; | ||
|
||
describe('listShowItemsQuery', () => { | ||
it('should query for shows on a list', async () => { | ||
const result = await runQuery({ | ||
factory: () => createQuery(listShowItemsQuery({ id: 1 })), | ||
mapper: (response) => response?.data, | ||
}); | ||
|
||
expect(result).to.deep.equal(ListedShowsMappedMock); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { ListedMovie } from '$lib/requests/queries/lists/listMovieItemsQuery.ts'; | ||
import { MovieMatrixMappedMock } from '$mocks/data/summary/movies/matrix/MovieMatrixMappedMock.ts'; | ||
|
||
export const ListedMoviesMappedMock: ListedMovie[] = [ | ||
{ | ||
'entry': MovieMatrixMappedMock, | ||
'id': 1146014560, | ||
'listedAt': new Date('2024-12-27T21:34:14.000Z'), | ||
'notes': null, | ||
'rank': 1, | ||
'type': 'movie', | ||
}, | ||
]; |
13 changes: 13 additions & 0 deletions
13
projects/client/src/mocks/data/lists/mapped/ListedShowsMappedMock.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,13 @@ | ||
import type { ListedShow } from '$lib/requests/queries/lists/listShowItemsQuery.ts'; | ||
import { ShowSiloMappedMock } from '$mocks/data/summary/shows/silo/mapped/ShowSiloMappedMock.ts'; | ||
|
||
export const ListedShowsMappedMock: ListedShow[] = [ | ||
{ | ||
'entry': ShowSiloMappedMock, | ||
'id': 1234, | ||
'listedAt': new Date('2024-12-27T21:34:14.000Z'), | ||
'notes': null, | ||
'rank': 1, | ||
'type': 'show', | ||
}, | ||
]; |
13 changes: 13 additions & 0 deletions
13
projects/client/src/mocks/data/lists/response/ListedMoviesResponseMock.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,13 @@ | ||
import { MovieMatrixResponseMock } from '$mocks/data/summary/movies/matrix/MovieMatrixResponseMock.ts'; | ||
import type { ListedMovieResponse } from '@trakt/api'; | ||
|
||
export const ListedMoviesResponseMock: ListedMovieResponse[] = [ | ||
{ | ||
'rank': 1, | ||
'id': 1146014560, | ||
'listed_at': '2024-12-27T21:34:14.000Z', | ||
'notes': null, | ||
'type': 'movie', | ||
'movie': MovieMatrixResponseMock, | ||
}, | ||
]; |
13 changes: 13 additions & 0 deletions
13
projects/client/src/mocks/data/lists/response/ListedShowsResponseMock.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,13 @@ | ||
import { ShowSiloResponseMock } from '$mocks/data/summary/shows/silo/response/ShowSiloResponseMock.ts'; | ||
import type { ListedShowResponse } from '@trakt/api'; | ||
|
||
export const ListedShowsResponseMock: ListedShowResponse[] = [ | ||
{ | ||
'rank': 1, | ||
'id': 1234, | ||
'listed_at': '2024-12-27T21:34:14.000Z', | ||
'notes': null, | ||
'type': 'show', | ||
'show': ShowSiloResponseMock, | ||
}, | ||
]; |
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,13 @@ | ||
import { ListedMoviesResponseMock } from '$mocks/data/lists/response/ListedMoviesResponseMock.ts'; | ||
import { ListedShowsResponseMock } from '$mocks/data/lists/response/ListedShowsResponseMock.ts'; | ||
|
||
import { http, HttpResponse } from 'msw'; | ||
|
||
export const lists = [ | ||
http.get(`http://localhost/lists/*/items/movies*`, () => { | ||
return HttpResponse.json(ListedMoviesResponseMock); | ||
}), | ||
http.get(`http://localhost/lists/*/items/shows*`, () => { | ||
return HttpResponse.json(ListedShowsResponseMock); | ||
}), | ||
]; |
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