Skip to content

Commit

Permalink
refactor: Visitor class now use assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
TesteurManiak committed Jul 3, 2024
1 parent 1c7c3f2 commit 56fcf7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
21 changes: 5 additions & 16 deletions lib/src/visitor.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
class Visitor {
factory Visitor({
String? id,
String? uid,
}) {
if (uid != null && uid.isEmpty) {
throw ArgumentError('Must not be empty', 'uid');
}

return Visitor._(
id: id,
uid: uid,
);
}

Visitor._({
const Visitor({
this.id,
this.uid,
});
}) : assert(
uid == null || uid.length != 0,
'uid must not be empty',
);

/// The unique visitor ID, must be a 16 characters hexadecimal string.
///
Expand Down
4 changes: 2 additions & 2 deletions test/src/visitor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import '../ressources/mock/data.dart';

void main() {
test('it should be able to create Visitor', () {
final visitor = Visitor(
const visitor = Visitor(
id: visitorId,
uid: uid,
);
Expand All @@ -22,6 +22,6 @@ void main() {
);
}

expect(getVisitorWithEmptyUserId, throwsArgumentError);
expect(getVisitorWithEmptyUserId, throwsAssertionError);
});
}

0 comments on commit 56fcf7c

Please sign in to comment.