@@ -60,7 +60,7 @@ void main() {
6060 test ('returns correct instance from JSON with all fields' , () {
6161 final json = {
6262 'id' : 'user-1' ,
63- 'followedCountries ' : [
63+ 'followed_countries ' : [
6464 {
6565 'id' : 'country-1' ,
6666 'iso_code' : 'US' ,
@@ -70,30 +70,30 @@ void main() {
7070 'action' : defaultAction.toJson (),
7171 },
7272 ],
73- 'followedSources ' : [
73+ 'followed_sources ' : [
7474 {
7575 'id' : 'source-1' ,
7676 'name' : 'Example News' ,
7777 'url' : 'http://example.com' ,
7878 'type' : 'source' ,
79- 'sourceType ' : 'news-agency ' ,
79+ 'source_type ' : 'news_agency ' ,
8080 'action' : defaultAction.toJson (),
8181 },
8282 ],
83- 'followedCategories ' : [
83+ 'followed_categories ' : [
8484 {
8585 'id' : 'category-1' ,
8686 'name' : 'Technology' ,
8787 'type' : 'category' ,
8888 'action' : defaultAction.toJson (),
8989 },
9090 ],
91- 'savedHeadlines ' : [
91+ 'saved_headlines ' : [
9292 {
9393 'id' : 'headline-1' ,
9494 'title' : 'Example Headline' ,
9595 'url' : 'http://example.com/headline' ,
96- 'publishedAt ' : '2023-01-01T00:00:00.000Z' ,
96+ 'published_at ' : '2023-01-01T00:00:00.000Z' ,
9797 'type' : 'headline' ,
9898 'action' : defaultAction.toJson (),
9999 },
@@ -116,10 +116,10 @@ void main() {
116116 test ('returns correct instance from JSON with empty lists' , () {
117117 final json = {
118118 'id' : 'user-3' ,
119- 'followedCountries ' : [],
120- 'followedSources ' : [],
121- 'followedCategories ' : [],
122- 'savedHeadlines ' : [],
119+ 'followed_countries ' : [],
120+ 'followed_sources ' : [],
121+ 'followed_categories ' : [],
122+ 'saved_headlines ' : [],
123123 };
124124
125125 final result = UserContentPreferences .fromJson (json);
@@ -135,7 +135,7 @@ void main() {
135135 () {
136136 final json = {
137137 'id' : 'user-4' ,
138- // Missing followedCountries, followedSources, followedCategories, savedHeadlines
138+ // Missing followed_countries, followed_sources, followed_categories, saved_headlines
139139 };
140140
141141 final result = UserContentPreferences .fromJson (json);
@@ -157,29 +157,29 @@ void main() {
157157 final json = preferencesWithSaved.toJson ();
158158
159159 expect (json['id' ], 'user-1' );
160- expect (json['followedCountries ' ], isA <List >());
161- expect ((json['followedCountries ' ] as List ).length, 1 );
162- expect ((json['followedCountries ' ] as List ).first['id' ], 'country-1' );
163- expect (json['followedSources ' ], isA <List >());
164- expect ((json['followedSources ' ] as List ).length, 1 );
165- expect ((json['followedSources ' ] as List ).first['id' ], 'source-1' );
166- expect (json['followedCategories ' ], isA <List >());
167- expect ((json['followedCategories ' ] as List ).length, 1 );
168- expect ((json['followedCategories ' ] as List ).first['id' ], 'category-1' );
169- expect (json['savedHeadlines ' ], isA <List >());
170- expect ((json['savedHeadlines ' ] as List ).length, 1 );
171- expect ((json['savedHeadlines ' ] as List ).first['id' ], 'headline-1' );
160+ expect (json['followed_countries ' ], isA <List >());
161+ expect ((json['followed_countries ' ] as List ).length, 1 );
162+ expect ((json['followed_countries ' ] as List ).first['id' ], 'country-1' );
163+ expect (json['followed_sources ' ], isA <List >());
164+ expect ((json['followed_sources ' ] as List ).length, 1 );
165+ expect ((json['followed_sources ' ] as List ).first['id' ], 'source-1' );
166+ expect (json['followed_categories ' ], isA <List >());
167+ expect ((json['followed_categories ' ] as List ).length, 1 );
168+ expect ((json['followed_categories ' ] as List ).first['id' ], 'category-1' );
169+ expect (json['saved_headlines ' ], isA <List >());
170+ expect ((json['saved_headlines ' ] as List ).length, 1 );
171+ expect ((json['saved_headlines ' ] as List ).first['id' ], 'headline-1' );
172172 });
173173
174174 test ('returns correct JSON map with empty lists' , () {
175175 const emptyPreferences = UserContentPreferences (id: 'user-5' );
176176 final json = emptyPreferences.toJson ();
177177
178178 expect (json['id' ], 'user-5' );
179- expect (json['followedCountries ' ], isEmpty);
180- expect (json['followedSources ' ], isEmpty);
181- expect (json['followedCategories ' ], isEmpty);
182- expect (json['savedHeadlines ' ], isEmpty);
179+ expect (json['followed_countries ' ], isEmpty);
180+ expect (json['followed_sources ' ], isEmpty);
181+ expect (json['followed_categories ' ], isEmpty);
182+ expect (json['saved_headlines ' ], isEmpty);
183183 });
184184 });
185185
0 commit comments