This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
generated from nogic1008/nuxt-ts-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use @vue/test-utils flushPromises & refactor type definitio…
…ns (#740) * refactor(test): use @vue/test-utils flushPromises * refactor: reduce any uses * refactor: move type definition
- Loading branch information
Showing
14 changed files
with
68 additions
and
66 deletions.
There are no files selected for viewing
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
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
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,16 +1,33 @@ | ||
import type { ParsedContent } from '@nuxt/content/dist/runtime/types' | ||
import type { Ref } from 'vue' | ||
|
||
import type { Software } from '~~/src/content' | ||
import type seriesList from '~~/content/series/.seriesList.json' | ||
|
||
export type SoftwareParsedContent = ParsedContent & Software | ||
export const regionList = ['JP', 'US', 'EU', 'None'] as const | ||
|
||
export const platforms = [ | ||
'Play Station', | ||
'Play Station 2', | ||
'Dreamcast', | ||
'GAME BOY COLOR', | ||
'Wii' | ||
] as const | ||
|
||
export interface Software { | ||
slug: keyof typeof seriesList | ||
title: string | ||
platform: (typeof platforms)[number] | ||
region: (typeof regionList)[number] | ||
launched: string | ||
difficulties: { [key in number]: { name: string; class: string } } | ||
} | ||
|
||
export default async function (slug: string) { | ||
const { data } = await useAsyncData(`/software/${slug}`, () => | ||
queryContent<SoftwareParsedContent>() | ||
queryContent<Software & ParsedContent>() | ||
.where({ _type: 'markdown', slug }) | ||
.findOne() | ||
) | ||
|
||
return { software: data as Ref<SoftwareParsedContent> } | ||
return { software: data as Ref<Software & ParsedContent> } | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
import type { ParsedContent } from '@nuxt/content/dist/runtime/types' | ||
import type { Ref } from 'vue' | ||
|
||
import type { Song } from '~~/src/content' | ||
import type seriesList from '~~/content/series/.seriesList.json' | ||
|
||
export interface Song { | ||
slug: string | ||
name: string | ||
artist: string | ||
bpm: number | string | ||
series: (keyof typeof seriesList)[] | ||
} | ||
|
||
export type SongParsedContent = ParsedContent & Song | ||
|
||
export default async function (slug: string) { | ||
const { data } = await useAsyncData(`/songs/${slug}`, () => | ||
queryContent<SongParsedContent>() | ||
queryContent<ParsedContent & Song>() | ||
.where({ _type: 'markdown', slug: { $eq: slug } }) | ||
.findOne() | ||
) | ||
|
||
return { song: data as Ref<SongParsedContent> } | ||
return { song: data as Ref<ParsedContent & Song> } | ||
} |
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,11 +1,14 @@ | ||
import type { Ref } from 'vue' | ||
|
||
import type { Song } from '~~/src/content' | ||
import type { Song } from '~~/composables/useSongData' | ||
|
||
export default async function (key: string, ...keys: (keyof Song)[]) { | ||
export default async function <T extends keyof Song>( | ||
key: string, | ||
...keys: T[] | ||
) { | ||
const { data } = await useAsyncData(key, () => | ||
queryContent<Song>('songs').sort({ name: 1 }).only(keys).find() | ||
) | ||
|
||
return { songs: data as Ref<Pick<Song, (typeof keys)[number]>[]> } | ||
return { songs: data as Ref<Pick<Song, T>[]> } | ||
} |
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 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