Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ginkgo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vjrj
ginkgo
Commits
7a6b8bfb
Commit
7a6b8bfb
authored
1 year ago
by
vjrj
Browse files
Options
Downloads
Patches
Plain Diff
humanize contact should only show publikey once (tests)
parent
e3185222
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/ui_test.dart
+88
-0
88 additions, 0 deletions
test/ui_test.dart
with
88 additions
and
0 deletions
test/ui_test.dart
+
88
−
0
View file @
7a6b8bfb
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:ginkgo/data/models/contact.dart'
;
import
'package:ginkgo/ui/ui_helpers.dart'
;
import
'package:ginkgo/ui/ui_helpers.dart'
;
void
main
()
{
void
main
()
{
...
@@ -76,4 +77,91 @@ void main() {
...
@@ -76,4 +77,91 @@ void main() {
validateDecimal
(
sep:
'.'
,
locale:
'en'
,
amount:
'0,45'
);
validateDecimal
(
sep:
'.'
,
locale:
'en'
,
amount:
'0,45'
);
expect
(
result
,
'enter_a_valid_number'
);
expect
(
result
,
'enter_a_valid_number'
);
});
});
group
(
'humanizeContact'
,
()
{
test
(
'Should return "your_wallet" if pubKey matches publicAddress'
,
()
{
const
String
publicAddress
=
'your_public_address'
;
const
Contact
contact
=
Contact
(
pubKey:
'your_public_address'
);
final
String
result
=
humanizeContact
(
publicAddress
,
contact
);
expect
(
result
,
'your_wallet'
);
});
test
(
'Should return contact title if pubKey does not match publicAddress'
,
()
{
const
String
publicAddress
=
'your_public_address'
;
const
Contact
contact
=
Contact
(
pubKey:
'other_public_address'
,
name:
'John Doe'
);
final
String
result
=
humanizeContact
(
publicAddress
,
contact
);
expect
(
result
,
'John Doe'
);
});
test
(
'Should return contact title with pubKey if addKey is true'
,
()
{
const
String
publicAddress
=
'your_public_address'
;
const
Contact
contact
=
Contact
(
pubKey:
'other_public_address'
,
name:
'John Doe'
);
final
String
result
=
humanizeContact
(
publicAddress
,
contact
,
true
);
expect
(
result
,
'John Doe (🔑 other_pu)'
);
});
test
(
'Should return pubKey if addKey is true but title is the same as pubKey'
,
()
{
const
String
publicAddress
=
'other_public_address'
;
const
Contact
contact
=
Contact
(
pubKey:
'your_public_address'
);
final
String
result
=
humanizeContact
(
publicAddress
,
contact
,
true
);
expect
(
result
,
'🔑 your_pub'
);
});
});
group
(
'Contact'
,
()
{
test
(
'Should return correct title when name and nick are both provided'
,
()
{
const
Contact
contact
=
Contact
(
pubKey:
'your_public_address'
,
name:
'John'
,
nick:
'JD'
);
final
String
result
=
contact
.
title
;
expect
(
result
,
'John (JD)'
);
});
test
(
'Should return name when name and nick are the same'
,
()
{
const
Contact
contact
=
Contact
(
pubKey:
'your_public_address'
,
name:
'John'
,
nick:
'John'
);
final
String
result
=
contact
.
title
;
expect
(
result
,
'John'
);
});
test
(
'Should return name when name is provided and nick is null'
,
()
{
const
Contact
contact
=
Contact
(
pubKey:
'your_public_address'
,
name:
'John'
);
final
String
result
=
contact
.
title
;
expect
(
result
,
'John'
);
});
test
(
'Should return nick when nick is provided and name is null'
,
()
{
const
Contact
contact
=
Contact
(
pubKey:
'your_public_address'
,
nick:
'JD'
);
final
String
result
=
contact
.
title
;
expect
(
result
,
'JD'
);
});
test
(
'Should return humanized pubKey when neither name nor nick is provided'
,
()
{
const
Contact
contact
=
Contact
(
pubKey:
'your_public_address'
);
final
String
result
=
contact
.
title
;
expect
(
result
,
'🔑 your_pub'
);
});
test
(
'Should return subtitle when nick or name is provided'
,
()
{
const
Contact
contact
=
Contact
(
pubKey:
'your_public_address'
,
nick:
'JD'
);
final
String
?
result
=
contact
.
subtitle
;
expect
(
result
,
'🔑 your_pub'
);
});
test
(
'Should return null subtitle when neither nick nor name is provided'
,
()
{
const
Contact
contact
=
Contact
(
pubKey:
'your_public_address'
);
final
String
?
result
=
contact
.
subtitle
;
expect
(
result
,
isNull
);
});
});
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment