-
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.
- Loading branch information
Showing
5 changed files
with
97 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {mount} from '@vue/test-utils'; | ||
import {describe, it, expect, beforeEach} from 'vitest'; | ||
import {useScheduleStore} from '@/stores/schedule'; | ||
import TrainingRating from '@/components/TrainingRating.vue'; | ||
import {getEmptyTraining} from '@/utils'; | ||
|
||
describe('TrainingCard', () => { | ||
let scheduleStore: ReturnType<typeof useScheduleStore>; | ||
|
||
beforeEach(() => { | ||
scheduleStore = useScheduleStore(); | ||
}); | ||
|
||
it('mounts', () => { | ||
const wrapper = mount(TrainingRating, { | ||
props: { | ||
training: getEmptyTraining(), | ||
}, | ||
}); | ||
expect(wrapper.html()).toMatchSnapshot(); | ||
}); | ||
|
||
it('calls store on rating change', async () => { | ||
const training = getEmptyTraining(); | ||
const wrapper = mount(TrainingRating, { | ||
props: { | ||
training: training, | ||
}, | ||
}); | ||
|
||
await wrapper.find('button:nth-child(1)').trigger('click'); | ||
expect(scheduleStore.updateRating).toHaveBeenLastCalledWith(training, 1); | ||
await wrapper.find('button:nth-child(2)').trigger('click'); | ||
expect(scheduleStore.updateRating).toHaveBeenLastCalledWith(training, 2); | ||
await wrapper.find('button:nth-child(3)').trigger('click'); | ||
expect(scheduleStore.updateRating).toHaveBeenLastCalledWith(training, 3); | ||
await wrapper.find('button:nth-child(4)').trigger('click'); | ||
expect(scheduleStore.updateRating).toHaveBeenLastCalledWith(training, 4); | ||
await wrapper.find('button:nth-child(5)').trigger('click'); | ||
expect(scheduleStore.updateRating).toHaveBeenLastCalledWith(training, 5); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
src/components/__tests__/__snapshots__/TrainingRating.spec.ts.snap
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,25 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`TrainingCard > mounts 1`] = ` | ||
"<div class="d-flex justify-space-evenly training-card__rating"><button type="button" class="v-btn v-btn--elevated v-btn--icon v-theme--light bg-transparent v-btn--density-default elevation-0 v-btn--size-small v-btn--variant-elevated"><span class="v-btn__overlay"></span><span class="v-btn__underlay"></span> | ||
<!----><span class="v-btn__content" data-no-activator=""><i class="mdi-star-outline mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i></span> | ||
<!----> | ||
<!----> | ||
</button><button type="button" class="v-btn v-btn--elevated v-btn--icon v-theme--light bg-transparent v-btn--density-default elevation-0 v-btn--size-small v-btn--variant-elevated"><span class="v-btn__overlay"></span><span class="v-btn__underlay"></span> | ||
<!----><span class="v-btn__content" data-no-activator=""><i class="mdi-star-outline mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i></span> | ||
<!----> | ||
<!----> | ||
</button><button type="button" class="v-btn v-btn--elevated v-btn--icon v-theme--light bg-transparent v-btn--density-default elevation-0 v-btn--size-small v-btn--variant-elevated"><span class="v-btn__overlay"></span><span class="v-btn__underlay"></span> | ||
<!----><span class="v-btn__content" data-no-activator=""><i class="mdi-star-outline mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i></span> | ||
<!----> | ||
<!----> | ||
</button><button type="button" class="v-btn v-btn--elevated v-btn--icon v-theme--light bg-transparent v-btn--density-default elevation-0 v-btn--size-small v-btn--variant-elevated"><span class="v-btn__overlay"></span><span class="v-btn__underlay"></span> | ||
<!----><span class="v-btn__content" data-no-activator=""><i class="mdi-star-outline mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i></span> | ||
<!----> | ||
<!----> | ||
</button><button type="button" class="v-btn v-btn--elevated v-btn--icon v-theme--light bg-transparent v-btn--density-default elevation-0 v-btn--size-small v-btn--variant-elevated"><span class="v-btn__overlay"></span><span class="v-btn__underlay"></span> | ||
<!----><span class="v-btn__content" data-no-activator=""><i class="mdi-star-outline mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i></span> | ||
<!----> | ||
<!----> | ||
</button></div>" | ||
`; |