-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF-3226 Parsing minInputLength from Autocomplete capability in session
- Loading branch information
Showing
7 changed files
with
293 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:jmap_dart_client/http/converter/unsigned_int_nullable_converter.dart'; | ||
import 'package:jmap_dart_client/jmap/core/capability/capability_properties.dart'; | ||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart'; | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
part 'autocomplete_capability.g.dart'; | ||
|
||
@JsonSerializable( | ||
explicitToJson: true, | ||
includeIfNull: false, | ||
converters: [ | ||
UnsignedIntNullableConverter() | ||
] | ||
) | ||
class AutocompleteCapability extends CapabilityProperties { | ||
final UnsignedInt? minInputLength; | ||
|
||
AutocompleteCapability({this.minInputLength}); | ||
|
||
factory AutocompleteCapability.fromJson(Map<String, dynamic> json) | ||
=> _$AutocompleteCapabilityFromJson(json); | ||
|
||
Map<String, dynamic> toJson() => _$AutocompleteCapabilityToJson(this); | ||
|
||
static AutocompleteCapability deserialize(Map<String, dynamic> json) { | ||
return AutocompleteCapability.fromJson(json); | ||
} | ||
|
||
@override | ||
List<Object?> get props => [minInputLength]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import 'package:contact/contact_module.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:jmap_dart_client/jmap/core/account/account.dart'; | ||
import 'package:jmap_dart_client/jmap/core/capability/empty_capability.dart'; | ||
import 'package:jmap_dart_client/jmap/core/session/session.dart'; | ||
import 'package:jmap_dart_client/jmap/core/state.dart'; | ||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart'; | ||
import 'package:jmap_dart_client/jmap/core/user_name.dart'; | ||
import 'package:tmail_ui_user/features/home/domain/extensions/session_extensions.dart'; | ||
|
||
import '../../fixtures/account_fixtures.dart'; | ||
|
||
void main() { | ||
group('getMinInputLengthAutocomplete::test', () { | ||
test('SHOULD return minInputLength WHEN AutocompleteCapability is available', () { | ||
// Arrange | ||
final autocompleteCapability = AutocompleteCapability(minInputLength: UnsignedInt(3)); | ||
final session = Session( | ||
{ | ||
tmailContactCapabilityIdentifier: autocompleteCapability | ||
}, | ||
{ | ||
AccountFixtures.aliceAccountId: Account( | ||
AccountName('Alice'), | ||
true, | ||
false, | ||
{ | ||
tmailContactCapabilityIdentifier: autocompleteCapability | ||
}, | ||
) | ||
}, | ||
{}, | ||
UserName(''), | ||
Uri(), | ||
Uri(), | ||
Uri(), | ||
Uri(), | ||
State('')); | ||
|
||
// Act | ||
final result = session.getMinInputLengthAutocomplete(AccountFixtures.aliceAccountId); | ||
|
||
// Assert | ||
expect(result, autocompleteCapability.minInputLength); | ||
}); | ||
|
||
test('SHOULD return null WHEN AutocompleteCapability is not available', () { | ||
// Arrange | ||
final session = Session( | ||
{ | ||
tmailContactCapabilityIdentifier: EmptyCapability() | ||
}, | ||
{ | ||
AccountFixtures.aliceAccountId: Account( | ||
AccountName('Alice'), | ||
true, | ||
false, | ||
{ | ||
tmailContactCapabilityIdentifier: EmptyCapability() | ||
}, | ||
) | ||
}, | ||
{}, | ||
UserName(''), | ||
Uri(), | ||
Uri(), | ||
Uri(), | ||
Uri(), | ||
State('')); | ||
|
||
// Act | ||
final result = session.getMinInputLengthAutocomplete(AccountFixtures.aliceAccountId); | ||
|
||
// Assert | ||
expect(result, isNull); | ||
}); | ||
|
||
test('SHOULD return null WHEN autocomplete capability is not supported', () { | ||
// Arrange | ||
final session = Session( | ||
{}, | ||
{ | ||
AccountFixtures.aliceAccountId: Account( | ||
AccountName('Alice'), | ||
true, | ||
false, | ||
{}, | ||
) | ||
}, | ||
{}, | ||
UserName(''), | ||
Uri(), | ||
Uri(), | ||
Uri(), | ||
Uri(), | ||
State('')); | ||
|
||
// Act | ||
final result = session.getMinInputLengthAutocomplete(AccountFixtures.aliceAccountId); | ||
|
||
// Assert | ||
expect(result, isNull); | ||
}); | ||
}); | ||
} |