Browse Source

Merge pull request #422 from Leptopoda/feature/tests

Feature/tests
pull/424/head
Nikolas Rimikis 1 year ago committed by GitHub
parent
commit
ed00f7520d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      packages/neon/neon/lib/src/utils/branding.dart
  2. 10
      packages/neon/neon/lib/src/utils/global_popups.dart
  3. 14
      packages/neon/neon/lib/src/utils/hex_color.dart
  4. 31
      packages/neon/neon/test/hex_color_test.dart

3
packages/neon/neon/lib/src/utils/branding.dart

@ -1,7 +1,8 @@
part of '../../neon.dart'; part of '../../neon.dart';
@immutable
class Branding { class Branding {
Branding({ const Branding({
required this.name, required this.name,
required this.logo, required this.logo,
this.legalese, this.legalese,

10
packages/neon/neon/lib/src/utils/global_popups.dart

@ -1,10 +1,16 @@
part of '../../neon.dart'; part of '../../neon.dart';
class GlobalPopups { class GlobalPopups {
factory GlobalPopups() => _instance ??= GlobalPopups._(); factory GlobalPopups() => instance ??= GlobalPopups._();
@visibleForTesting
factory GlobalPopups.mocked(final GlobalPopups mock) => instance ??= mock;
GlobalPopups._(); GlobalPopups._();
static GlobalPopups? _instance; @visibleForTesting
static GlobalPopups? instance;
bool _registered = false; bool _registered = false;
void register(final BuildContext context) { void register(final BuildContext context) {

14
packages/neon/neon/lib/src/utils/hex_color.dart

@ -1,11 +1,11 @@
part of '../../neon.dart'; part of '../../neon.dart';
class HexColor extends Color { class HexColor extends Color {
HexColor(final String hexColor) HexColor(final String hexColor) : super(_parse(hexColor));
: super(
int.parse( static int _parse(final String hexColor) {
hexColor.toUpperCase().replaceAll('#', '').padLeft(8, 'F'), final formated = hexColor.toUpperCase().replaceAll('#', '').padLeft(8, 'F');
radix: 16,
), return int.parse(formated, radix: 16);
); }
} }

31
packages/neon/neon/test/hex_color_test.dart

@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
import 'package:neon/neon.dart';
import 'package:test/test.dart';
void main() {
group('HexColor', () {
test('White', () {
final color = HexColor('#ffffffff');
expect(color.value, equals(Colors.white.value));
});
test('Without alpha', () {
final color = HexColor('#ffffff');
expect(color.value, equals(Colors.white.value));
});
test('Without #', () {
final color = HexColor('ffffffff');
expect(color.value, equals(Colors.white.value));
});
test('Uppercase', () {
final color = HexColor('#FFFFFFFF');
expect(color.value, equals(Colors.white.value));
});
});
}
Loading…
Cancel
Save