@@ -68,6 +68,7 @@ describe('DatetimeCardEditor.svelte', () => {
6868 expect ( eventDispatcher ) . toHaveBeenCalledWith ( "config-changed" , {
6969 config : {
7070 entities : [ { "id" : "" , "max" : 0 } ] ,
71+ flex_direction : "row" ,
7172 image : "" ,
7273 show_names : false ,
7374 title : "My Datetime Card" ,
@@ -84,6 +85,7 @@ describe('DatetimeCardEditor.svelte', () => {
8485 expect ( eventDispatcher ) . toHaveBeenCalledWith ( "config-changed" , {
8586 config : {
8687 entities : [ { id : "" , max : 0 } , ] ,
88+ flex_direction : "row" ,
8789 image : "/local/image.png" ,
8890 show_names : false ,
8991 type : "custom:datetime-card" ,
@@ -100,6 +102,7 @@ describe('DatetimeCardEditor.svelte', () => {
100102 expect ( eventDispatcher ) . toHaveBeenCalledWith ( "config-changed" , {
101103 config : {
102104 entities : [ { id : "" , max : 0 } , ] ,
105+ flex_direction : "row" ,
103106 image : "" ,
104107 show_names : true ,
105108 type : "custom:datetime-card" ,
@@ -108,6 +111,59 @@ describe('DatetimeCardEditor.svelte', () => {
108111 } ) ;
109112 } ) ;
110113
114+ test ( "when column changes config should change" , async ( ) => {
115+ getByLabelText ( "Column" ) . checked = true ;
116+
117+ await fireEvent . change ( getByLabelText ( "Column" ) ) ;
118+
119+ expect ( eventDispatcher ) . toHaveBeenCalledWith ( "config-changed" , {
120+ config : {
121+ entities : [ { id : "" , max : 0 } , ] ,
122+ flex_direction : "column" ,
123+ image : "" ,
124+ show_names : false ,
125+ type : "custom:datetime-card" ,
126+ title : ""
127+ }
128+ } ) ;
129+ } ) ;
130+
131+ test ( "when reverse changes config should change" , async ( ) => {
132+ getByLabelText ( "Reverse" ) . checked = true ;
133+
134+ await fireEvent . change ( getByLabelText ( "Reverse" ) ) ;
135+
136+ expect ( eventDispatcher ) . toHaveBeenCalledWith ( "config-changed" , {
137+ config : {
138+ entities : [ { id : "" , max : 0 } , ] ,
139+ flex_direction : "row-reverse" ,
140+ image : "" ,
141+ show_names : false ,
142+ type : "custom:datetime-card" ,
143+ title : ""
144+ }
145+ } ) ;
146+ } ) ;
147+
148+ test ( "when column and reverse change config should change" , async ( ) => {
149+ getByLabelText ( "Column" ) . checked = true ;
150+ getByLabelText ( "Reverse" ) . checked = true ;
151+
152+ await fireEvent . change ( getByLabelText ( "Column" ) ) ;
153+ await fireEvent . change ( getByLabelText ( "Reverse" ) ) ;
154+
155+ expect ( eventDispatcher ) . toHaveBeenCalledWith ( "config-changed" , {
156+ config : {
157+ entities : [ { id : "" , max : 0 } , ] ,
158+ flex_direction : "column-reverse" ,
159+ image : "" ,
160+ show_names : false ,
161+ type : "custom:datetime-card" ,
162+ title : ""
163+ }
164+ } ) ;
165+ } ) ;
166+
111167 test ( "when click on plus a new entity should be added" , async ( ) => {
112168 await fireEvent . click ( getByTestId ( "plus" ) ) ;
113169
@@ -135,6 +191,20 @@ describe('DatetimeCardEditor.svelte', () => {
135191 expect ( getByLabelText ( "Show names" ) ) . toHaveAttribute ( "checked" , "true" ) ;
136192 } ) ;
137193
194+ [ { flex_direction : "column" , column : "true" , reverse : "false" } ,
195+ { flex_direction : "row" , column : "false" , reverse : "false" } ,
196+ { flex_direction : "column-reverse" , column : "true" , reverse : "true" } ,
197+ { flex_direction : "row-reverse" , column : "false" , reverse : "true" }
198+ ] . forEach ( ( { flex_direction, column, reverse } ) => {
199+ test ( `when flex_direction is ${ flex_direction } ` , async ( ) => {
200+ const config = { flex_direction } ;
201+ await component . setConfig ( config ) ;
202+
203+ expect ( getByLabelText ( "Column" ) ) . toHaveAttribute ( "checked" , column ) ;
204+ expect ( getByLabelText ( "Reverse" ) ) . toHaveAttribute ( "checked" , reverse ) ;
205+ } ) ;
206+ } ) ;
207+
138208 describe ( "when config.entities is not empty" , ( ) => {
139209 let entity1 : IEntity ;
140210 let entity2 : IEntity ;
@@ -175,6 +245,7 @@ describe('DatetimeCardEditor.svelte', () => {
175245 expect ( eventDispatcher ) . toHaveBeenCalledWith ( "config-changed" , {
176246 config : {
177247 entities : [ { id : "input_datetime.test" , "max" : 10 } , entity2 ] ,
248+ flex_direction : "row" ,
178249 image : "" ,
179250 show_names : false ,
180251 title : "" ,
@@ -191,6 +262,7 @@ describe('DatetimeCardEditor.svelte', () => {
191262 expect ( eventDispatcher ) . toHaveBeenCalledWith ( "config-changed" , {
192263 config : {
193264 entities : [ { "id" : "input_datetime.test_1" , "max" : 20 } , entity2 ] ,
265+ flex_direction : "row" ,
194266 image : "" ,
195267 show_names : false ,
196268 title : "" ,
@@ -213,6 +285,7 @@ describe('DatetimeCardEditor.svelte', () => {
213285 expect ( eventDispatcher ) . toHaveBeenCalledWith ( "config-changed" , {
214286 config : {
215287 entities : [ { "id" : "input_datetime.test_2" , "max" : 20 , } ] ,
288+ flex_direction : "row" ,
216289 image : "" ,
217290 show_names : false ,
218291 title : "" ,
@@ -231,6 +304,7 @@ describe('DatetimeCardEditor.svelte', () => {
231304 expect ( eventDispatcher ) . toHaveBeenCalledWith ( "config-changed" , {
232305 config : {
233306 entities : [ ] ,
307+ flex_direction : "row" ,
234308 image : "" ,
235309 show_names : false ,
236310 title : "" ,
0 commit comments