@@ -2,6 +2,7 @@ import Day from '@/app/pages/Days/Day.vue'
22import PageObject from '../../../__page_objects__/PageObject'
33import { fakeGigsByDay } from '../../../services/__mocks__/gigs-sample'
44import { Wrap } from '../../../../../test/helpers'
5+ import DayListPageObject from '../../../__page_objects__/DayPageObject' ;
56
67const FIRST_DAY = fakeGigsByDay [ 0 ]
78
@@ -11,8 +12,9 @@ describe('Day', () => {
1112 beforeEach ( async ( ) => {
1213 wrapper = Wrap ( Day )
1314 . withProps ( { day : FIRST_DAY , isLoading : false , onClick : jest . fn } )
15+ . withRouter ( jest . fn ( ) )
1416 . mount ( )
15- page = new PageObject ( wrapper )
17+ page = new DayListPageObject ( wrapper )
1618 await page . updateAsync ( )
1719 } )
1820
@@ -26,4 +28,26 @@ describe('Day', () => {
2628 it ( 'renders gig' , async ( ) => {
2729 page . contains ( FIRST_DAY . day )
2830 } )
31+
32+
33+ describe ( 'When clicking buttons' , ( ) => {
34+
35+ let navigateToGigSpy
36+ beforeEach ( async ( ) => {
37+ navigateToGigSpy = jest . fn ( )
38+ page . setRouterSpy ( { navigateToGig : navigateToGigSpy } )
39+ } )
40+
41+ it ( 'navigates to first gig detail' , async ( ) => {
42+ const FIRST_GIG = FIRST_DAY . gigs [ 0 ]
43+ page . clickFirstGig ( )
44+ expect ( navigateToGigSpy ) . toHaveBeenCalledWith ( FIRST_GIG . id )
45+ } )
46+
47+ it ( 'navigates to second gig detail' , async ( ) => {
48+ const SECOND_GIG = FIRST_DAY . gigs [ 1 ]
49+ page . clickSecondGig ( )
50+ expect ( navigateToGigSpy ) . toHaveBeenCalledWith ( SECOND_GIG . id )
51+ } )
52+ } )
2953} )
0 commit comments