feat : refresh login
test: core
This commit is contained in:
43
packages/core/test/presentation/common/app_color_test.dart
Normal file
43
packages/core/test/presentation/common/app_color_test.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:rasadyar_core/presentation/common/app_color.dart';
|
||||
|
||||
|
||||
void main() {
|
||||
group('AppColor', () {
|
||||
test('blue colors', () {
|
||||
expect(AppColor.blueLight, const Color(0xFFeaefff));
|
||||
expect(AppColor.blueLightHover, const Color(0xFFe0e7ff));
|
||||
expect(AppColor.blueLightActive, const Color(0xFFbecdff));
|
||||
expect(AppColor.blueNormal, const Color(0xFF2d5fff));
|
||||
expect(AppColor.blueNormalHover, const Color(0xFF2956e6));
|
||||
expect(AppColor.blueNormalActive, const Color(0xFF244ccc));
|
||||
expect(AppColor.blueDark, const Color(0xFF2247bf));
|
||||
expect(AppColor.blueDarkHover, const Color(0xFF1b3999));
|
||||
expect(AppColor.blueDarkActive, const Color(0xFF142b73));
|
||||
expect(AppColor.blueDarker, const Color(0xFF102159));
|
||||
});
|
||||
|
||||
test('green colors', () {
|
||||
expect(AppColor.greenLight, const Color(0xFFe6faf5));
|
||||
expect(AppColor.greenLightHover, const Color(0xFFd9f7f0));
|
||||
expect(AppColor.greenLightActive, const Color(0xFFb0efdf));
|
||||
expect(AppColor.greenNormal, const Color(0xFF00cc99));
|
||||
expect(AppColor.greenNormalHover, const Color(0xFF00b88a));
|
||||
expect(AppColor.greenNormalActive, const Color(0xFF00a37a));
|
||||
expect(AppColor.greenDark, const Color(0xFF009973));
|
||||
expect(AppColor.greenDarkHover, const Color(0xFF007a5c));
|
||||
expect(AppColor.greenDarkActive, const Color(0xFF005c45));
|
||||
expect(AppColor.greenDarker, const Color(0xFF004736));
|
||||
});
|
||||
|
||||
test('category colors', () {
|
||||
expect(AppColor.confirm, AppColor.greenNormalActive);
|
||||
expect(AppColor.warning, AppColor.yellowNormal);
|
||||
expect(AppColor.error, AppColor.redNormal);
|
||||
expect(AppColor.info, AppColor.tealNormal);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
35
packages/core/test/presentation/utils/color_utils_test.dart
Normal file
35
packages/core/test/presentation/utils/color_utils_test.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:rasadyar_core/presentation/utils/color_utils.dart';
|
||||
|
||||
void main() {
|
||||
group('ColorUtils extension', () {
|
||||
const baseColor = Color(0xFF42A5F5);
|
||||
|
||||
test('disabledColor returns color with alpha 38', () {
|
||||
Color disabled = baseColor.disabledColor;
|
||||
expect(disabled.a, 0.14901960784313725);
|
||||
expect(disabled.r, baseColor.r);
|
||||
expect(disabled.g, baseColor.g);
|
||||
expect(disabled.b, baseColor.b);
|
||||
});
|
||||
|
||||
test('hoverColor returns color darkened by 0.5', () {
|
||||
Color hover = baseColor.hoverColor;
|
||||
final expected =
|
||||
HSLColor.fromColor(
|
||||
baseColor,
|
||||
).withLightness((HSLColor.fromColor(baseColor).lightness - 0.5).clamp(0.0, 1.0)).toColor();
|
||||
expect(hover.g, expected.g);
|
||||
});
|
||||
|
||||
test('pressedColor returns color darkened by 0.1', () {
|
||||
Color pressed = baseColor.pressedColor;
|
||||
final expected =
|
||||
HSLColor.fromColor(
|
||||
baseColor,
|
||||
).withLightness((HSLColor.fromColor(baseColor).lightness - 0.1).clamp(0.0, 1.0)).toColor();
|
||||
expect(pressed.r, expected.r);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:rasadyar_core/presentation/utils/list_extensions.dart';
|
||||
|
||||
void main(){
|
||||
group('toggle test', (){
|
||||
|
||||
List<int> list = [1, 2, 3];
|
||||
|
||||
test('should remove item if it exists', () {
|
||||
list.toggle(2);
|
||||
expect(list, [1, 3]);
|
||||
});
|
||||
|
||||
|
||||
test('should add item if it not exists', () {
|
||||
list.toggle(10);
|
||||
expect(list, [1, 3 , 10]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
group('insert to first item' ,(){
|
||||
|
||||
List<int> list = [1, 2, 3];
|
||||
|
||||
test('should insert item at start if it does not exist', () {
|
||||
list.ensureContainsAtStart(0);
|
||||
expect(list, [0, 1, 2, 3]);
|
||||
});
|
||||
|
||||
test('should not insert item at start if it already exists', () {
|
||||
list.ensureContainsAtStart(2);
|
||||
expect(list, [0, 1, 2, 3]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
group('clear and add item' ,(){
|
||||
|
||||
List<int> list = [1, 2, 3];
|
||||
|
||||
test('must be clear and add item ', () {
|
||||
list.resetWith(20);
|
||||
expect(list, [20]);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user