@@ -84,4 +84,130 @@ describe("SomedayEventContainer keyboard interactions", () => {
8484 Categories_Event . SOMEDAY_WEEK ,
8585 ) ;
8686 } ) ;
87+
88+ it ( "migrates event to Someday Week when Meta+Ctrl+ArrowUp is pressed" , async ( ) => {
89+ const onSubmit = jest . fn ( ) ;
90+ const contextValue = {
91+ state : {
92+ draft : null ,
93+ isDrafting : false ,
94+ isOverGrid : false ,
95+ isSomedayFormOpen : false ,
96+ } as any ,
97+ setters : {
98+ setIsSomedayFormOpen : jest . fn ( ) ,
99+ } as any ,
100+ actions : {
101+ onDraft : jest . fn ( ) ,
102+ onMigrate : jest . fn ( ) ,
103+ discard : jest . fn ( ) ,
104+ reset : jest . fn ( ) ,
105+ closeForm : jest . fn ( ) ,
106+ close : jest . fn ( ) ,
107+ onSubmit,
108+ } as any ,
109+ } ;
110+
111+ const weekViewRange = { startDate : "2020-01-05" , endDate : "2020-01-11" } ;
112+
113+ render (
114+ < SidebarDraftContext . Provider value = { contextValue as any } >
115+ < SomedayEventContainer
116+ category = { Categories_Event . SOMEDAY_MONTH }
117+ event = { LEARN_CHINESE }
118+ isDrafting = { false }
119+ isDragging = { false }
120+ isOverGrid = { false }
121+ onSubmit = { onSubmit }
122+ provided = {
123+ {
124+ draggableProps : {
125+ "data-rfd-draggable-context-id" : "mock-context" ,
126+ "data-rfd-draggable-id" : "mock-id" ,
127+ style : { } ,
128+ } ,
129+ dragHandleProps : null ,
130+ innerRef : jest . fn ( ) ,
131+ } as DraggableProvided
132+ }
133+ snapshot = { { isDragging : false } as DraggableStateSnapshot }
134+ setEvent = { jest . fn ( ) }
135+ weekViewRange = { weekViewRange }
136+ />
137+ </ SidebarDraftContext . Provider > ,
138+ ) ;
139+
140+ const btn = document . querySelector (
141+ `[data-event-id="${ LEARN_CHINESE . _id } "]` ,
142+ ) ! as HTMLElement ;
143+ btn . focus ( ) ;
144+ fireEvent . keyDown ( btn , { key : "ArrowUp" , metaKey : true , ctrlKey : true } ) ;
145+
146+ expect ( onSubmit ) . toHaveBeenCalledTimes ( 1 ) ;
147+
148+ // TODO: Do a date validation
149+ } ) ;
150+
151+ it ( "migrates event to Someday Month when Meta+Ctrl+ArrowDown is pressed" , async ( ) => {
152+ const onSubmit = jest . fn ( ) ;
153+ const contextValue = {
154+ state : {
155+ draft : null ,
156+ isDrafting : false ,
157+ isOverGrid : false ,
158+ isSomedayFormOpen : false ,
159+ } as any ,
160+ setters : {
161+ setIsSomedayFormOpen : jest . fn ( ) ,
162+ } as any ,
163+ actions : {
164+ onDraft : jest . fn ( ) ,
165+ onMigrate : jest . fn ( ) ,
166+ discard : jest . fn ( ) ,
167+ reset : jest . fn ( ) ,
168+ closeForm : jest . fn ( ) ,
169+ close : jest . fn ( ) ,
170+ onSubmit,
171+ } as any ,
172+ } ;
173+
174+ const weekViewRange = { startDate : "2020-01-01" , endDate : "2020-01-07" } ;
175+
176+ render (
177+ < SidebarDraftContext . Provider value = { contextValue as any } >
178+ < SomedayEventContainer
179+ category = { Categories_Event . SOMEDAY_WEEK }
180+ event = { LEARN_CHINESE }
181+ isDrafting = { false }
182+ isDragging = { false }
183+ isOverGrid = { false }
184+ onSubmit = { onSubmit }
185+ provided = {
186+ {
187+ draggableProps : {
188+ "data-rfd-draggable-context-id" : "mock-context" ,
189+ "data-rfd-draggable-id" : "mock-id" ,
190+ style : { } ,
191+ } ,
192+ dragHandleProps : null ,
193+ innerRef : jest . fn ( ) ,
194+ } as DraggableProvided
195+ }
196+ snapshot = { { isDragging : false } as DraggableStateSnapshot }
197+ setEvent = { jest . fn ( ) }
198+ weekViewRange = { weekViewRange }
199+ />
200+ </ SidebarDraftContext . Provider > ,
201+ ) ;
202+
203+ const btn = document . querySelector (
204+ `[data-event-id="${ LEARN_CHINESE . _id } "]` ,
205+ ) ! as HTMLElement ;
206+ btn . focus ( ) ;
207+ fireEvent . keyDown ( btn , { key : "ArrowDown" , metaKey : true , ctrlKey : true } ) ;
208+
209+ expect ( onSubmit ) . toHaveBeenCalledTimes ( 1 ) ;
210+
211+ // TODO: Do a date validation
212+ } ) ;
87213} ) ;
0 commit comments