Browse Source

Merge pull request #422 from Leptopoda/feature/tests

Feature/tests
pull/424/head
Nikolas Rimikis 2 years 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';
@immutable
class Branding {
Branding({
const Branding({
required this.name,
required this.logo,
this.legalese,

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

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

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

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