Skip to content

Commit 3369378

Browse files
Merge pull request #2 from sipra-acharya/widget_testing
gfcard test cases
2 parents 8d97210 + 000b887 commit 3369378

File tree

1 file changed

+37
-73
lines changed

1 file changed

+37
-73
lines changed

test/card_test.dart

Lines changed: 37 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Future<void> main() async {
3030
padding: padding,
3131
margin: margin,
3232
title: title,
33-
content: content);
33+
content: childWidget);
3434

3535
final TestApp app = TestApp(card);
3636

@@ -44,7 +44,7 @@ Future<void> main() async {
4444
expect(app.card.padding, padding);
4545
expect(app.card.margin, margin);
4646
expect(app.card.title, title);
47-
expect(app.card.content, content);
47+
expect(app.card.content, childWidget);
4848
});
4949

5050
testWidgets('GF Card with color gradient.', (tester) async {
@@ -53,13 +53,13 @@ Future<void> main() async {
5353
end: Alignment.bottomRight,
5454
colors: [Colors.red, Colors.pink]);
5555
const GFCard card = GFCard(
56-
gradient: gradient,
57-
elevation: elevation,
58-
borderOnForeground: borderonForeground,
59-
padding: padding,
60-
margin: margin,
61-
title: title,
62-
content: content);
56+
gradient: gradient,
57+
elevation: elevation,
58+
borderOnForeground: borderonForeground,
59+
padding: padding,
60+
margin: margin,
61+
title: title,
62+
);
6363

6464
const TestApp app = TestApp(card);
6565

@@ -73,7 +73,6 @@ Future<void> main() async {
7373
expect(app.card.padding, padding);
7474
expect(app.card.margin, margin);
7575
expect(app.card.title, title);
76-
expect(app.card.content, content);
7776
});
7877

7978
testWidgets('GF Card with clip behaviour.', (tester) async {
@@ -141,13 +140,11 @@ Future<void> main() async {
141140
const scontainer = false;
142141

143142
const GFCard card = GFCard(
144-
semanticContainer: scontainer,
145-
elevation: elevation,
146-
borderOnForeground: borderonForeground,
147-
padding: padding,
148-
margin: margin,
149-
title: title,
150-
content: content);
143+
semanticContainer: scontainer,
144+
elevation: elevation,
145+
borderOnForeground: borderonForeground,
146+
title: title,
147+
);
151148

152149
const TestApp app = TestApp(card);
153150

@@ -158,10 +155,7 @@ Future<void> main() async {
158155
expect(app.card.semanticContainer, scontainer);
159156
expect(app.card.elevation, elevation);
160157
expect(app.card.borderOnForeground, borderonForeground);
161-
expect(app.card.padding, padding);
162-
expect(app.card.margin, margin);
163158
expect(app.card.title, title);
164-
expect(app.card.content, content);
165159
});
166160

167161
testWidgets('GF Card with title position.', (tester) async {
@@ -188,9 +182,6 @@ Future<void> main() async {
188182
'https://images.unsplash.com/photo-1547721064-da6cfb341d50',
189183
);
190184
final GFCard card = GFCard(
191-
color: color,
192-
padding: padding,
193-
margin: margin,
194185
title: title,
195186
border: border,
196187
borderRadius: borderradius,
@@ -201,14 +192,10 @@ Future<void> main() async {
201192

202193
await tester.pumpWidget(Container(child: childWidget));
203194
expect(find.byWidget(childWidget), findsOneWidget);
204-
expect(app.card.color, color);
205-
expect(app.card.padding, padding);
206-
expect(app.card.margin, margin);
207195
expect(app.card.title, title);
208196
expect(app.card.border, border);
209197
expect(app.card.borderRadius, borderradius);
210198
expect(app.card.content, content);
211-
212199
expect(app.card.image, bgImage);
213200
});
214201

@@ -227,13 +214,12 @@ Future<void> main() async {
227214
],
228215
);
229216
final GFCard card = GFCard(
230-
color: color,
231-
elevation: elevation,
232-
padding: padding,
233-
buttonBar: custombuttonbar,
234-
title: title,
235-
image: bgImage,
236-
content: content);
217+
color: color,
218+
elevation: elevation,
219+
buttonBar: custombuttonbar,
220+
title: title,
221+
image: bgImage,
222+
);
237223

238224
final TestApp app = TestApp(card);
239225

@@ -242,8 +228,6 @@ Future<void> main() async {
242228
expect(app.card.color, color);
243229
expect(app.card.elevation, elevation);
244230
expect(app.card.buttonBar, custombuttonbar);
245-
expect(app.card.padding, padding);
246-
expect(app.card.content, content);
247231
expect(app.card.image, bgImage);
248232
});
249233

@@ -253,11 +237,9 @@ Future<void> main() async {
253237
icon: Icon(Icons.favorite_border),
254238
);
255239
final GFCard card = GFCard(
256-
color: color,
257-
elevation: elevation,
258-
padding: padding,
259-
title: customtitle,
260-
content: content);
240+
color: color,
241+
title: customtitle,
242+
);
261243

262244
final TestApp app = TestApp(card);
263245

@@ -266,10 +248,7 @@ Future<void> main() async {
266248
await tester.pumpWidget(Container(child: childWidget));
267249
expect(find.byWidget(childWidget), findsOneWidget);
268250
expect(app.card.color, color);
269-
expect(app.card.elevation, elevation);
270-
expect(app.card.padding, padding);
271251
expect(app.card.title, customtitle);
272-
expect(app.card.content, content);
273252
});
274253

275254
testWidgets('GF Card with GFAvatar & Subtitle in title section.',
@@ -281,11 +260,9 @@ Future<void> main() async {
281260
icon: Icon(Icons.favorite_border),
282261
);
283262
final GFCard card = GFCard(
284-
color: color,
285-
elevation: elevation,
286-
padding: padding,
287-
title: customtitle,
288-
content: content);
263+
color: color,
264+
title: customtitle,
265+
);
289266

290267
final TestApp app = TestApp(card);
291268

@@ -294,10 +271,7 @@ Future<void> main() async {
294271
await tester.pumpWidget(Container(child: childWidget));
295272
expect(find.byWidget(childWidget), findsOneWidget);
296273
expect(app.card.color, color);
297-
expect(app.card.elevation, elevation);
298-
expect(app.card.padding, padding);
299274
expect(app.card.title, customtitle);
300-
expect(app.card.content, content);
301275
});
302276

303277
testWidgets('GF Card with full background image & buttonbar.',
@@ -311,23 +285,18 @@ Future<void> main() async {
311285
subtitleText: 'Sub title',
312286
);
313287
final GFCard card = GFCard(
314-
color: color,
315-
elevation: elevation,
316-
padding: padding,
317-
title: customtitle,
318-
imageOverlay: imageoverlay,
319-
colorFilter: colorfilter,
320-
content: content);
288+
color: color,
289+
title: customtitle,
290+
imageOverlay: imageoverlay,
291+
colorFilter: colorfilter,
292+
);
321293

322294
final TestApp app = TestApp(card);
323295

324296
await tester.pumpWidget(Container(child: childWidget));
325297
expect(find.byWidget(childWidget), findsOneWidget);
326298
expect(app.card.color, color);
327-
expect(app.card.elevation, elevation);
328-
expect(app.card.padding, padding);
329299
expect(app.card.title, customtitle);
330-
expect(app.card.content, content);
331300
expect(app.card.imageOverlay, imageoverlay);
332301
expect(app.card.colorFilter, colorfilter);
333302
});
@@ -356,24 +325,19 @@ Future<void> main() async {
356325
],
357326
);
358327
final GFCard card = GFCard(
359-
color: color,
360-
elevation: elevation,
361-
padding: padding,
362-
title: customtitle,
363-
imageOverlay: imageoverlay,
364-
colorFilter: colorfilter,
365-
buttonBar: custombuttonbar,
366-
content: content);
328+
color: color,
329+
title: customtitle,
330+
imageOverlay: imageoverlay,
331+
colorFilter: colorfilter,
332+
buttonBar: custombuttonbar,
333+
);
367334

368335
final TestApp app = TestApp(card);
369336

370337
await tester.pumpWidget(Container(child: childWidget));
371338
expect(find.byWidget(childWidget), findsOneWidget);
372339
expect(app.card.color, color);
373-
expect(app.card.elevation, elevation);
374-
expect(app.card.padding, padding);
375340
expect(app.card.title, customtitle);
376-
expect(app.card.content, content);
377341
expect(app.card.imageOverlay, imageoverlay);
378342
expect(app.card.colorFilter, colorfilter);
379343
expect(app.card.buttonBar, custombuttonbar);

0 commit comments

Comments
 (0)