-
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: define better query runner which does not require string parsing
- Loading branch information
1 parent
56a41c4
commit 8f031e3
Showing
34 changed files
with
175 additions
and
287 deletions.
There are no files selected for viewing
14 changes: 4 additions & 10 deletions
14
projects/client/src/lib/features/auth/queries/currentUserHistoryQuery.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 |
---|---|---|
@@ -1,22 +1,16 @@ | ||
import QueryTestBed from '$test/beds/query/QueryTestBed.svelte'; | ||
|
||
import { UserHistoryMappedMock } from '$mocks/data/users/UserHistoryMappedMock'; | ||
import { waitForQueryResult } from '$test/beds/query/waitForQueryResult.ts'; | ||
import { runQuery } from '$test/beds/query/runQuery.ts'; | ||
import { createQuery } from '@tanstack/svelte-query'; | ||
import { render } from '@testing-library/svelte'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { currentUserHistoryQuery } from './currentUserHistoryQuery'; | ||
|
||
describe('currentUserHistoryQuery', () => { | ||
it('should query for user user history', async () => { | ||
render(QueryTestBed, { | ||
props: { | ||
queryFactory: () => createQuery(currentUserHistoryQuery()), | ||
mapper: (response) => response?.data, | ||
}, | ||
const result = await runQuery({ | ||
factory: () => createQuery(currentUserHistoryQuery()), | ||
mapper: (response) => response?.data, | ||
}); | ||
|
||
const result = await waitForQueryResult(); | ||
expect(result).to.deep.equal(UserHistoryMappedMock); | ||
}); | ||
}); |
14 changes: 4 additions & 10 deletions
14
projects/client/src/lib/features/auth/queries/currentUserSettingsQuery.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 |
---|---|---|
@@ -1,22 +1,16 @@ | ||
import QueryTestBed from '$test/beds/query/QueryTestBed.svelte'; | ||
|
||
import { ExtendedUserMappedMock } from '$mocks/data/users/ExtendedUserSettingsMappedMock.ts'; | ||
import { waitForQueryResult } from '$test/beds/query/waitForQueryResult.ts'; | ||
import { runQuery } from '$test/beds/query/runQuery.ts'; | ||
import { createQuery } from '@tanstack/svelte-query'; | ||
import { render } from '@testing-library/svelte'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { currentUserSettingsQuery } from './currentUserSettingsQuery.ts'; | ||
|
||
describe('currentUserSettingsQuery', () => { | ||
it('should query for user profile', async () => { | ||
render(QueryTestBed, { | ||
props: { | ||
queryFactory: () => createQuery(currentUserSettingsQuery()), | ||
mapper: (response) => response?.data, | ||
}, | ||
const result = await runQuery({ | ||
factory: () => createQuery(currentUserSettingsQuery()), | ||
mapper: (response) => response?.data, | ||
}); | ||
|
||
const result = await waitForQueryResult(); | ||
expect(result).to.deep.equal(ExtendedUserMappedMock); | ||
}); | ||
}); |
12 changes: 3 additions & 9 deletions
12
projects/client/src/lib/features/auth/stores/useUser.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 |
---|---|---|
@@ -1,20 +1,14 @@ | ||
import QueryTestBed from '$test/beds/query/QueryTestBed.svelte'; | ||
|
||
import { ExtendedUserMappedMock } from '$mocks/data/users/ExtendedUserSettingsMappedMock.ts'; | ||
import { waitForQueryResult } from '$test/beds/query/waitForQueryResult.ts'; | ||
import { render } from '@testing-library/svelte'; | ||
import { runQuery } from '$test/beds/query/runQuery.ts'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { useUser } from './useUser.ts'; | ||
|
||
describe('store: useUser', () => { | ||
it('should contain the user profile', async () => { | ||
render(QueryTestBed, { | ||
props: { | ||
queryFactory: () => useUser().user, | ||
}, | ||
const result = await runQuery({ | ||
factory: () => useUser().user, | ||
}); | ||
|
||
const result = await waitForQueryResult(); | ||
expect(result).to.deep.equal(ExtendedUserMappedMock); | ||
}); | ||
}); |
16 changes: 5 additions & 11 deletions
16
projects/client/src/lib/requests/queries/movies/movieSummaryQuery.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 |
---|---|---|
@@ -1,23 +1,17 @@ | ||
import QueryTestBed from '$test/beds/query/QueryTestBed.svelte'; | ||
|
||
import { MovieHereticMappedMock } from '$mocks/data/summary/movies/heretic/mapped/MovieHereticMappedMock.ts'; | ||
import { waitForQueryResult } from '$test/beds/query/waitForQueryResult.ts'; | ||
import { runQuery } from '$test/beds/query/runQuery.ts'; | ||
import { createQuery } from '@tanstack/svelte-query'; | ||
import { render } from '@testing-library/svelte'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { movieSummaryQuery } from './movieSummaryQuery.ts'; | ||
|
||
describe('movieSummaryQuery', () => { | ||
it('should query for Heretic (2024)', async () => { | ||
render(QueryTestBed, { | ||
props: { | ||
queryFactory: () => | ||
createQuery(movieSummaryQuery({ slug: MovieHereticMappedMock.slug })), | ||
mapper: (response) => response?.data, | ||
}, | ||
const result = await runQuery({ | ||
factory: () => | ||
createQuery(movieSummaryQuery({ slug: MovieHereticMappedMock.slug })), | ||
mapper: (response) => response?.data, | ||
}); | ||
|
||
const result = await waitForQueryResult(); | ||
expect(result).to.deep.equal(MovieHereticMappedMock); | ||
}); | ||
}); |
18 changes: 5 additions & 13 deletions
18
projects/client/src/lib/requests/queries/shows/showSummaryQuery.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 |
---|---|---|
@@ -1,25 +1,17 @@ | ||
import QueryTestBed from '$test/beds/query/QueryTestBed.svelte'; | ||
|
||
import { waitForQueryResult } from '$test/beds/query/waitForQueryResult.ts'; | ||
import { runQuery } from '$test/beds/query/runQuery.ts'; | ||
import { createQuery } from '@tanstack/svelte-query'; | ||
import { render } from '@testing-library/svelte'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { ShowSiloMappedMock } from '../../../../mocks/data/summary/shows/silo/mapped/ShowSiloMappedMock.ts'; | ||
import { showSummaryQuery } from './showSummaryQuery.ts'; | ||
|
||
describe('showSummaryQuery', () => { | ||
it('should query for Silo (2023)', async () => { | ||
render(QueryTestBed, { | ||
props: { | ||
queryFactory: () => | ||
createQuery( | ||
showSummaryQuery({ slug: ShowSiloMappedMock.slug }), | ||
), | ||
mapper: (response) => response?.data, | ||
}, | ||
const result = await runQuery({ | ||
factory: () => | ||
createQuery(showSummaryQuery({ slug: ShowSiloMappedMock.slug })), | ||
mapper: (response) => response?.data, | ||
}); | ||
|
||
const result = await waitForQueryResult(); | ||
expect(result).to.deep.equal(ShowSiloMappedMock); | ||
}); | ||
}); |
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
4 changes: 3 additions & 1 deletion
4
...s/client/src/mocks/data/summary/movies/heretic/mapped/MovieHereticPortugueseMappedMock.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
4 changes: 3 additions & 1 deletion
4
...ects/client/src/mocks/data/summary/movies/heretic/mapped/MovieHereticRatingsMappedMock.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
4 changes: 3 additions & 1 deletion
4
projects/client/src/mocks/data/summary/movies/heretic/mapped/MovieHereticStatsMappedMock.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
4 changes: 3 additions & 1 deletion
4
...ects/client/src/mocks/data/summary/movies/heretic/mapped/MovieHereticStudiosMappedMock.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
30 changes: 0 additions & 30 deletions
30
projects/client/src/mocks/data/summary/movies/heretic/mapped/MovieStudiosMappedMock.ts
This file was deleted.
Oops, something went wrong.
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
4 changes: 3 additions & 1 deletion
4
projects/client/src/mocks/data/summary/shows/silo/mapped/ShowSiloJapaneseMappedMock.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
4 changes: 3 additions & 1 deletion
4
projects/client/src/mocks/data/summary/shows/silo/mapped/ShowSiloPeopleMappedMock.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
Oops, something went wrong.