From 3cb2b5e9b41f50bab5dd34ff126fe12f9877694b Mon Sep 17 00:00:00 2001 From: JvnSlv Date: Wed, 31 Jul 2024 12:04:43 +0200 Subject: [PATCH] Add golden tests for small button widget --- packages/widget_toolkit/example/pubspec.lock | 2 +- .../buttons/factory/small_button_factory.dart | 7 ++++++ .../buttons/small_button_test.dart | 23 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 packages/widget_toolkit/test/lib_ui_components/buttons/factory/small_button_factory.dart create mode 100644 packages/widget_toolkit/test/lib_ui_components/buttons/small_button_test.dart diff --git a/packages/widget_toolkit/example/pubspec.lock b/packages/widget_toolkit/example/pubspec.lock index 69645222..43829ab5 100644 --- a/packages/widget_toolkit/example/pubspec.lock +++ b/packages/widget_toolkit/example/pubspec.lock @@ -752,7 +752,7 @@ packages: path: ".." relative: true source: path - version: "0.1.0" + version: "0.1.1" xml: dependency: transitive description: diff --git a/packages/widget_toolkit/test/lib_ui_components/buttons/factory/small_button_factory.dart b/packages/widget_toolkit/test/lib_ui_components/buttons/factory/small_button_factory.dart new file mode 100644 index 00000000..6c8a7bd9 --- /dev/null +++ b/packages/widget_toolkit/test/lib_ui_components/buttons/factory/small_button_factory.dart @@ -0,0 +1,7 @@ +import 'package:flutter/material.dart'; +import 'package:widget_toolkit/ui_components.dart'; + +Widget smallButtonFactory({ + required ButtonStateModel state, +}) => + SmallButton(onPressed: () {}, icon: Icons.add, state: state); diff --git a/packages/widget_toolkit/test/lib_ui_components/buttons/small_button_test.dart b/packages/widget_toolkit/test/lib_ui_components/buttons/small_button_test.dart new file mode 100644 index 00000000..5a6cb872 --- /dev/null +++ b/packages/widget_toolkit/test/lib_ui_components/buttons/small_button_test.dart @@ -0,0 +1,23 @@ +import 'package:widget_toolkit/ui_components.dart'; + +import '../../helpers/golden_helper.dart'; +import '../../helpers/models/scenario.dart'; +import 'factory/small_button_factory.dart'; +// Import your SmallButton widget and other necessary files + +void main() { + runGoldenTests([ + generateDeviceBuilder( + widget: smallButtonFactory(state: ButtonStateModel.loading), + scenario: Scenario(name: 'small_button_loading')), + generateDeviceBuilder( + widget: smallButtonFactory(state: ButtonStateModel.enabled), + scenario: Scenario(name: 'small_button_enabled')), + generateDeviceBuilder( + widget: smallButtonFactory(state: ButtonStateModel.disabled), + scenario: Scenario(name: 'small_button_disabled')), + generateDeviceBuilder( + widget: smallButtonFactory(state: ButtonStateModel.pressed), + scenario: Scenario(name: 'small_button_pressed')), + ]); +}