Skip to content

Commit

Permalink
Add golden tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pante committed Jun 1, 2024
1 parent 5fac718 commit 6a12975
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 11 deletions.
18 changes: 9 additions & 9 deletions forui/lib/src/widgets/switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ class FSwitch extends StatelessWidget {
/// Creates a [FSwitch].
const FSwitch({
required this.value,
required this.onChanged,
super.key,
this.style,
this.onChanged,
this.autofocus = false,
this.focusNode,
this.onFocusChange,
Expand All @@ -92,14 +92,14 @@ class FSwitch extends StatelessWidget {
return CupertinoSwitch(
value: value,
onChanged: onChanged,
// activeColor: style.checked,
// trackColor: style.unchecked,
// thumbColor: style.thumb,
// focusColor: style.focus,
// autofocus: autofocus,
// focusNode: focusNode,
// onFocusChange: onFocusChange,
// dragStartBehavior: dragStartBehavior,
activeColor: style.checked,
trackColor: style.unchecked,
thumbColor: style.thumb,
focusColor: style.focus,
autofocus: autofocus,
focusNode: focusNode,
onFocusChange: onFocusChange,
dragStartBehavior: dragStartBehavior,
);
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified forui/test/golden/switch/zinc-dark-checked-unfocused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified forui/test/golden/switch/zinc-dark-unchecked-unfocused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified forui/test/golden/switch/zinc-light-checked-unfocused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified forui/test/golden/switch/zinc-light-unchecked-unfocused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 45 additions & 2 deletions forui/test/src/widgets/switch_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import '../test_scaffold.dart';
void main() {
group('FSeparator', () {
for (final (name, theme, _) in TestScaffold.themes) {
for (final (checked, value) in [('checked', true)]) {
for (final (checked, value) in [('checked', true), ('unchecked', false)]) {
testWidgets('$name - $checked - unfocused', (tester) async {
await tester.pumpWidget(
TestScaffold(
data: theme,
child: Center(
child: FSwitch(value: value),
child: FSwitch(
value: value,
onChanged: (_) {},
),
),
),
);
Expand All @@ -23,6 +26,46 @@ void main() {
matchesGoldenFile('switch/$name-$checked-unfocused.png'),
);
});

testWidgets('$name - $checked - focused', (tester) async {
await tester.pumpWidget(
TestScaffold(
data: theme,
child: Center(
child: FSwitch(
value: value,
autofocus: true,
onChanged: (_) {},
),
),
),
);

await expectLater(
find.byType(TestScaffold),
matchesGoldenFile('switch/$name-$checked-focused.png'),
);
});

testWidgets('$name - $checked - disabled', (tester) async {
await tester.pumpWidget(
TestScaffold(
data: theme,
child: Center(
child: FSwitch(
value: value,
autofocus: true,
onChanged: null,
),
),
),
);

await expectLater(
find.byType(TestScaffold),
matchesGoldenFile('switch/$name-$checked-disabled.png'),
);
});
}
}
});
Expand Down

0 comments on commit 6a12975

Please sign in to comment.