Skip to content

Commit

Permalink
tests: add golden tests for all buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
smallTrogdor committed Dec 11, 2024
1 parent b74f36f commit 1052eea
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 0 deletions.
Binary file added test/goldens/icon_button.dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/goldens/icon_button.light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/goldens/primary_button.dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/goldens/primary_button.light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/goldens/secondary_button.dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/goldens/secondary_button.light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/goldens/tertiary_button.dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/goldens/tertiary_button.light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions test/sbb_icon_button_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sbb_design_system_mobile/sbb_design_system_mobile.dart';

import 'test_app.dart';

void main() {
testWidgets('icon_button', (WidgetTester tester) async {
final widget = Padding(
padding: const EdgeInsets.symmetric(horizontal: sbbDefaultSpacing / 2),
child: Column(
children: [
const SizedBox(height: sbbDefaultSpacing),
SBBIconButtonLarge(onPressed: () {}, icon: SBBIcons.glass_cocktail_medium),
const SizedBox(height: sbbDefaultSpacing),
SBBIconButtonLarge(onPressed: null, icon: SBBIcons.glass_cocktail_medium),
const SizedBox(height: sbbDefaultSpacing),
SBBIconButtonSmall(onPressed: () {}, icon: SBBIcons.glass_cocktail_small),
const SizedBox(height: sbbDefaultSpacing),
SBBIconButtonSmall(onPressed: null, icon: SBBIcons.glass_cocktail_small),
],
),
);
await TestSpecs.run(
TestSpecs.themedSpecs,
widget,
tester,
'icon_button',
find.byType(Column).first,
);
});
}
28 changes: 28 additions & 0 deletions test/sbb_primary_button_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sbb_design_system_mobile/sbb_design_system_mobile.dart';

import 'test_app.dart';

void main() {
testWidgets('primary_button', (WidgetTester tester) async {
final widget = Padding(
padding: const EdgeInsets.symmetric(horizontal: sbbDefaultSpacing / 2),
child: Column(
children: [
const SizedBox(height: sbbDefaultSpacing),
SBBPrimaryButton(label: "Default", onPressed: () {}),
const SizedBox(height: sbbDefaultSpacing),
SBBPrimaryButton(label: "Disabled", onPressed: null),
],
),
);
await TestSpecs.run(
TestSpecs.themedSpecs,
widget,
tester,
'primary_button',
find.byType(Column).first,
);
});
}
29 changes: 29 additions & 0 deletions test/sbb_secondary_button_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sbb_design_system_mobile/sbb_design_system_mobile.dart';

import 'test_app.dart';

void main() {
testWidgets('secondary_button', (WidgetTester tester) async {
final widget = Padding(
padding: const EdgeInsets.symmetric(horizontal: sbbDefaultSpacing / 2),

child: Column(
children: [
const SizedBox(height: sbbDefaultSpacing),
SBBSecondaryButton(label: "Default", onPressed: () {}),
const SizedBox(height: sbbDefaultSpacing),
SBBSecondaryButton(label: "Disabled", onPressed: null),
],
),
);
await TestSpecs.run(
TestSpecs.themedSpecs,
widget,
tester,
'secondary_button',
find.byType(Column).first,
);
});
}
40 changes: 40 additions & 0 deletions test/sbb_tertiary_button_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sbb_design_system_mobile/sbb_design_system_mobile.dart';

import 'test_app.dart';

void main() {
testWidgets('tertiary_button', (WidgetTester tester) async {
final widget = Padding(
padding: const EdgeInsets.symmetric(horizontal: sbbDefaultSpacing / 2),
child: Column(
children: [
const SizedBox(height: sbbDefaultSpacing),
SBBTertiaryButtonLarge(label: "Default", onPressed: () {}),
const SizedBox(height: sbbDefaultSpacing),
SBBTertiaryButtonLarge(label: "Disabled", onPressed: null),
const SizedBox(height: sbbDefaultSpacing),
SBBTertiaryButtonLarge(label: "Icon", onPressed: () {}, icon: SBBIcons.dog_medium),
const SizedBox(height: sbbDefaultSpacing),
SBBTertiaryButtonLarge(label: "Icon Disabled", onPressed: null, icon: SBBIcons.dog_medium),
const SizedBox(height: sbbDefaultSpacing),
SBBTertiaryButtonSmall(label: "Default", onPressed: () {}),
const SizedBox(height: sbbDefaultSpacing),
SBBTertiaryButtonSmall(label: "Disabled", onPressed: null),
const SizedBox(height: sbbDefaultSpacing),
SBBTertiaryButtonSmall(label: "Icon", onPressed: () {}, icon: SBBIcons.dog_small),
const SizedBox(height: sbbDefaultSpacing),
SBBTertiaryButtonSmall(label: "Icon Disabled", onPressed: null, icon: SBBIcons.dog_small),
],
),
);
await TestSpecs.run(
TestSpecs.themedSpecs,
widget,
tester,
'tertiary_button',
find.byType(Column).first,
);
});
}

0 comments on commit 1052eea

Please sign in to comment.