Skip to content

Commit 5f54efb

Browse files
committed
feat: remove PostCategory enum
1 parent e2d6b31 commit 5f54efb

24 files changed

+51
-83
lines changed

flutter_news_example/api/packages/news_blocks/test/src/article_introduction_block_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:test/test.dart';
44
void main() {
55
group('ArticleIntroductionBlock', () {
66
test('can be (de)serialized', () {
7-
const category = Category.technology;
7+
const category = Category(id: 'technology', name: 'Technology');
88
final block = ArticleIntroductionBlock(
99
categoryId: category.id,
1010
author: 'author',

flutter_news_example/api/packages/news_blocks/test/src/news_block_test.dart

+8-8
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void main() {
7777
});
7878

7979
test('returns VideoIntroductionBlock', () {
80-
const category = Category.technology;
80+
const category = Category(id: 'technology', name: 'Technology');
8181
final block = VideoIntroductionBlock(
8282
categoryId: category.id,
8383
title: 'title',
@@ -87,7 +87,7 @@ void main() {
8787
});
8888

8989
test('returns ArticleIntroductionBlock', () {
90-
const category = Category.technology;
90+
const category = Category(id: 'technology', name: 'Technology');
9191
final block = ArticleIntroductionBlock(
9292
categoryId: category.id,
9393
author: 'author',
@@ -99,7 +99,7 @@ void main() {
9999
});
100100

101101
test('returns PostLargeBlock', () {
102-
const category = Category.technology;
102+
const category = Category(id: 'technology', name: 'Technology');
103103
final block = PostLargeBlock(
104104
id: 'id',
105105
categoryId: category.id,
@@ -113,7 +113,7 @@ void main() {
113113
});
114114

115115
test('returns PostMediumBlock', () {
116-
const category = Category.sports;
116+
const category = Category(id: 'sports', name: 'Sports');
117117
final block = PostMediumBlock(
118118
id: 'id',
119119
categoryId: category.id,
@@ -127,7 +127,7 @@ void main() {
127127
});
128128

129129
test('returns PostSmallBlock', () {
130-
const category = Category.health;
130+
const category = Category(id: 'health', name: 'Health');
131131
final block = PostSmallBlock(
132132
id: 'id',
133133
categoryId: category.id,
@@ -141,7 +141,7 @@ void main() {
141141
});
142142

143143
test('returns PostGridGroupBlock', () {
144-
const category = Category.science;
144+
const category = Category(id: 'science', name: 'Science');
145145
final block = PostGridGroupBlock(
146146
categoryId: category.id,
147147
tiles: [
@@ -160,7 +160,7 @@ void main() {
160160
});
161161

162162
test('returns PostGridTileBlock', () {
163-
const category = Category.science;
163+
const category = Category(id: 'science', name: 'Science');
164164
final block = PostGridTileBlock(
165165
id: 'id',
166166
categoryId: category.id,
@@ -221,7 +221,7 @@ void main() {
221221
});
222222

223223
test('returns TrendingStoryBlock', () {
224-
const category = Category.health;
224+
const category = Category(id: 'health', name: 'Health');
225225
final content = PostSmallBlock(
226226
id: 'id',
227227
categoryId: category.id,

flutter_news_example/api/packages/news_blocks/test/src/news_blocks_converter_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ void main() {
77
group('NewsBlocksConverter', () {
88
test('can (de)serialize List<NewsBlock>', () {
99
final converter = NewsBlocksConverter();
10-
const category = Category.health;
10+
const category = Category(id: 'health', name: 'Health');
1111
final newsBlocks = <NewsBlock>[
1212
SectionHeaderBlock(title: 'title'),
1313
DividerHorizontalBlock(),

flutter_news_example/api/packages/news_blocks/test/src/post_block_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class CustomPostBlock extends PostBlock {
77
CustomPostBlock({super.action})
88
: super(
99
id: 'id',
10-
categoryId: Category.health.id,
10+
categoryId: Category(id: 'health', name: 'Health').id,
1111
author: 'author',
1212
publishedAt: DateTime(2022, 03, 09),
1313
title: 'title',

flutter_news_example/api/packages/news_blocks/test/src/post_grid_group_block_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:test/test.dart';
44
void main() {
55
group('PostGridGroupBlock', () {
66
test('can be (de)serialized', () {
7-
const category = Category.science;
7+
const category = Category(id: 'science', name: 'Science');
88
final block = PostGridGroupBlock(
99
categoryId: category.id,
1010
tiles: [

flutter_news_example/api/packages/news_blocks/test/src/post_grid_tile_block_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:test/test.dart';
44
void main() {
55
group('PostGridTileBlock', () {
66
test('can be (de)serialized', () {
7-
const category = Category.science;
7+
const category = Category(id: 'science', name: 'Science');
88
final block = PostGridTileBlock(
99
id: 'id',
1010
categoryId: category.id,
@@ -19,7 +19,7 @@ void main() {
1919

2020
group('PostGridTitleBlockExt', () {
2121
const id = 'id';
22-
const category = Category.science;
22+
const category = Category(id: 'science', name: 'Science');
2323
const author = 'author';
2424
final publishedAt = DateTime(2022, 3, 12);
2525
const imageUrl = 'imageUrl';

flutter_news_example/api/packages/news_blocks/test/src/post_large_block_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:test/test.dart';
44
void main() {
55
group('PostLargeBlock', () {
66
test('can be (de)serialized', () {
7-
const category = Category.technology;
7+
const category = Category(id: 'technology', name: 'Technology');
88
final block = PostLargeBlock(
99
id: 'id',
1010
categoryId: category.id,

flutter_news_example/api/packages/news_blocks/test/src/post_medium_block_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:test/test.dart';
44
void main() {
55
group('PostMediumBlock', () {
66
test('can be (de)serialized', () {
7-
const category = Category.sports;
7+
const category = Category(id: 'sports', name: 'Sports');
88
final block = PostMediumBlock(
99
id: 'id',
1010
categoryId: category.id,

flutter_news_example/api/packages/news_blocks/test/src/post_small_block_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:test/test.dart';
55
void main() {
66
group('PostSmallBlock', () {
77
test('can be (de)serialized', () {
8-
const category = Category.health;
8+
const category = Category(id: 'health', name: 'Health');
99
final block = PostSmallBlock(
1010
id: 'id',
1111
categoryId: category.id,

flutter_news_example/api/packages/news_blocks/test/src/trending_story_block_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:test/test.dart';
66
void main() {
77
group('TrendingStoryBlock', () {
88
test('can be (de)serialized', () {
9-
const category = Category.health;
9+
const category = Category(id: 'health', name: 'Health');
1010
final content = PostSmallBlock(
1111
id: 'id',
1212
categoryId: category.id,

flutter_news_example/api/packages/news_blocks/test/src/video_intro_block_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:test/test.dart';
66
void main() {
77
group('VideoIntroductionBlock', () {
88
test('can be (de)serialized', () {
9-
const category = Category.technology;
9+
const category = Category(id: 'technology', name: 'Technology');
1010
final block = VideoIntroductionBlock(
1111
categoryId: category.id,
1212
title: 'title',

flutter_news_example/lib/article/widgets/article_content.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class ArticleContent extends StatelessWidget {
2323
final hasMoreContent =
2424
context.select((ArticleBloc bloc) => bloc.state.hasMoreContent);
2525

26-
/// Show loader while categories are loading as article blocks may need
27-
/// to consume them.
26+
/// Show loader while categories are loading as articles may need to consume
27+
/// them
2828
if (status == ArticleStatus.initial ||
2929
categoriesStatus == CategoriesStatus.initial) {
3030
return const ArticleContentLoaderItem(

flutter_news_example/lib/categories/bloc/categories_bloc.g.dart

-32
This file was deleted.

flutter_news_example/packages/news_blocks_ui/test/src/article_introduction_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:news_blocks_ui/news_blocks_ui.dart';
77
import '../helpers/helpers.dart';
88

99
void main() {
10-
const category = Category.technology;
10+
const category = Category(id: 'technology', name: 'Technology');
1111
const author = 'Sean Hollister';
1212
final publishedAt = DateTime(2022, 3, 9);
1313
const imageUrl =

flutter_news_example/packages/news_blocks_ui/test/src/post_grid_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import '../helpers/helpers.dart';
1010

1111
void main() {
1212
group('PostGrid', () {
13-
const category = Category.science;
13+
const category = Category(id: 'science', name: 'Science');
1414
final postGridTileBlock = PostGridTileBlock(
1515
id: '842e3193-86d2-4069-a7e6-f769faa6f970',
1616
categoryId: category.id,

flutter_news_example/packages/news_blocks_ui/test/src/post_large/post_large_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import '../../helpers/helpers.dart';
1111

1212
void main() {
1313
const id = '499305f6-5096-4051-afda-824dcfc7df23';
14-
const category = Category.technology;
14+
const category = Category(id: 'technology', name: 'Technology');
1515
const author = 'Sean Hollister';
1616
final publishedAt = DateTime(2022, 3, 9);
1717
const imageUrl =

flutter_news_example/packages/news_blocks_ui/test/src/post_medium/post_medium_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void main() {
2424

2525
group('PostMedium', () {
2626
const id = '82c49bf1-946d-4920-a801-302291f367b5';
27-
const category = Category.sports;
27+
const category = Category(id: 'sports', name: 'Sports');
2828
const author = 'Tom Dierberger';
2929
final publishedAt = DateTime(2022, 3, 10);
3030
const imageUrl =

flutter_news_example/packages/news_blocks_ui/test/src/post_small_test.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void main() {
2222
});
2323

2424
testWidgets('renders correctly without image', (tester) async {
25-
const category = Category.technology;
25+
const category = Category(id: 'technology', name: 'Technology');
2626
await mockNetworkImages(() async {
2727
await tester.pumpApp(
2828
Column(
@@ -49,7 +49,7 @@ void main() {
4949
});
5050

5151
testWidgets('renders correctly with image', (tester) async {
52-
const category = Category.technology;
52+
const category = Category(id: 'technology', name: 'Technology');
5353
await mockNetworkImages(() async {
5454
await tester.pumpApp(
5555
Column(
@@ -80,7 +80,7 @@ void main() {
8080
testWidgets('onPressed is called with action when tapped', (tester) async {
8181
final action = NavigateToArticleAction(articleId: 'id');
8282
final actions = <BlockAction>[];
83-
const category = Category.technology;
83+
const category = Category(id: 'technology', name: 'Technology');
8484

8585
await mockNetworkImages(() async {
8686
await tester.pumpApp(

flutter_news_example/packages/news_blocks_ui/test/src/trending_story_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void main() {
2121
});
2222

2323
testWidgets('renders correctly', (tester) async {
24-
const category = Category.technology;
24+
const category = Category(id: 'technology', name: 'Technology');
2525
await mockNetworkImages(() async {
2626
final widget = TrendingStory(
2727
title: 'TRENDING',

flutter_news_example/packages/news_blocks_ui/test/src/video_introduction_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'package:video_player_platform_interface/video_player_platform_interface.
1111
import '../helpers/helpers.dart';
1212

1313
void main() {
14-
const category = Category.technology;
14+
const category = Category(id: 'technology', name: 'Technology');
1515
const videoUrl =
1616
'https://cdn.vox-cdn.com/thumbor/OTpmptgr7XcTVAJ27UBvIxl0vrg='
1717
'/0x146:2040x1214/fit-in/1200x630/cdn.vox-cdn.com/uploads/chorus_asset'

flutter_news_example/test/article/widgets/article_content_item_test.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void main() {
152152
testWidgets(
153153
'renders ArticleIntroduction '
154154
'for ArticleIntroductionBlock', (tester) async {
155-
const category = Category.technology;
155+
const category = Category(id: 'technology', name: 'Technology');
156156
final block = ArticleIntroductionBlock(
157157
categoryId: category.id,
158158
author: 'author',
@@ -179,7 +179,7 @@ void main() {
179179
'renders VideoIntroduction '
180180
'for VideoIntroductionBlock', (tester) async {
181181
setUpVideoPlayerPlatform();
182-
const category = Category.technology;
182+
const category = Category(id: 'technology', name: 'Technology');
183183
final block = VideoIntroductionBlock(
184184
categoryId: category.id,
185185
title: 'title',
@@ -268,7 +268,7 @@ void main() {
268268
testWidgets(
269269
'renders TrendingStory '
270270
'for TrendingStoryBlock', (tester) async {
271-
const category = Category.health;
271+
const category = Category(id: 'health', name: 'Health');
272272
final content = PostSmallBlock(
273273
id: 'id',
274274
categoryId: category.id,

flutter_news_example/test/article/widgets/article_trailing_content_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void main() {
2828
group('ArticleTrailingContent', () {
2929
late ArticleBloc articleBloc;
3030
late AppBloc appBloc;
31-
const category = Category.technology;
31+
const category = Category(id: 'technology', name: 'Technology');
3232

3333
final postSmallBlock = PostSmallBlock(
3434
id: '36f4a017-d099-4fce-8727-1d9ca6a0398c',

0 commit comments

Comments
 (0)