diff --git a/src/components/LearnsetList.vue b/src/components/LearnsetList.vue new file mode 100644 index 0000000..a13e472 --- /dev/null +++ b/src/components/LearnsetList.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/src/components/__tests__/LearnsetList.spec.ts b/src/components/__tests__/LearnsetList.spec.ts new file mode 100644 index 0000000..0d0a001 --- /dev/null +++ b/src/components/__tests__/LearnsetList.spec.ts @@ -0,0 +1,36 @@ +import vuetify from '@/utils/setupVuetify'; +import { render } from '@testing-library/vue'; +import LearnsetList from '@/components/LearnsetList.vue'; + +describe(`LearnsetList Component`, () => { + it(`카드 뭉치 이름과 삭제 버튼이 렌더링된다.`, () => { + const learnsets = [ + { + id: '', + name: '카드 뭉치 1', + created: 0, + cards: [], + }, + { + id: '', + name: '카드 뭉치 2', + created: 0, + cards: [], + }, + ]; + + const { getByText, getAllByRole } = render(LearnsetList, { + global: { + plugins: [vuetify], + }, + props: { + learnsets, + }, + }); + + expect(getByText(learnsets[0].name)).toBeInTheDocument(); + expect(getByText(learnsets[1].name)).toBeInTheDocument(); + + expect(getAllByRole('button').length).toBe(2); + }); +}); diff --git a/src/views/DashboardView.vue b/src/views/DashboardView.vue index 46b942d..97784da 100644 --- a/src/views/DashboardView.vue +++ b/src/views/DashboardView.vue @@ -1,14 +1,31 @@ @@ -18,6 +35,7 @@ import type { File } from '@/types/interfaces'; import BaseButton from '@/components/BaseButton.vue'; import AddLearnsetModal from '@/components/AddLearnsetModal.vue'; +import LearnsetList from '@/components/LearnsetList.vue'; import { ref, reactive } from 'vue'; @@ -28,8 +46,11 @@ import { MutationTypes } from '@/store/mutations'; import { useMarkdownIt } from '@/plugins/markdownit'; import { useRouter } from 'vue-router'; +import type { MyStore } from '@/store/types'; -const store = useStore(); +const store: MyStore = useStore(); + +const learnsets = store.state.learnsets; const md = useMarkdownIt(); @@ -75,4 +96,9 @@ const addLearnset = (name: string) => { }; - +