fix(core): fix tests

This commit is contained in:
Salvatore Giordano
2021-11-19 15:58:46 +01:00
parent b5f8c6333d
commit ffeed57c8f
4 changed files with 14 additions and 64 deletions
@@ -476,7 +476,7 @@ void main() {
_stateSetter?.call(() => limit = 6);
final updatedChannels = _generateChannels(mockClient, count: limit);
final updatedPagination = pagination.copyWith(limit: limit);
final updatedPagination = PaginationParams(limit: limit);
when(() => mockClient.queryChannels(
filter: any(named: 'filter'),
sort: any(named: 'sort'),
@@ -518,7 +518,7 @@ void main() {
_stateSetter?.call(() => limit = 6);
final updatedMessageResponseList = _generateMessages(count: limit);
final updatedPagination = pagination.copyWith(limit: limit);
final updatedPagination = PaginationParams(limit: limit);
when(() => mockClient.search(
testFilter,
query: any(named: 'query'),
@@ -189,9 +189,7 @@ void main() {
membersPagination: any(named: 'membersPagination'),
watchersPagination: any(named: 'watchersPagination'),
preferOffline: any(named: 'preferOffline'),
)).called(
2, // Fetching After messages + Fetching Before messages,
);
)).called(1);
},
);
@@ -214,14 +212,10 @@ void main() {
child: const Offstage(key: childKey),
);
final beforePagination = PaginationParams(
lessThan: initialMessageId,
limit: 20,
);
final afterPagination = PaginationParams(
greaterThanOrEqual: initialMessageId,
limit: 20,
final paginationParams = PaginationParams(
idAround: initialMessageId,
after: 20,
before: 20,
);
when(() => mockChannel.initialized).thenAnswer((_) async => true);
@@ -232,17 +226,7 @@ void main() {
state: any(named: 'state'),
watch: any(named: 'watch'),
presence: any(named: 'presence'),
messagesPagination: beforePagination,
membersPagination: any(named: 'membersPagination'),
watchersPagination: any(named: 'watchersPagination'),
preferOffline: any(named: 'preferOffline'),
)).thenAnswer((_) async => ChannelState(messages: messages));
when(() => mockChannel.query(
state: any(named: 'state'),
watch: any(named: 'watch'),
presence: any(named: 'presence'),
messagesPagination: afterPagination,
messagesPagination: paginationParams,
membersPagination: any(named: 'membersPagination'),
watchersPagination: any(named: 'watchersPagination'),
preferOffline: any(named: 'preferOffline'),
@@ -267,17 +251,7 @@ void main() {
state: any(named: 'state'),
watch: any(named: 'watch'),
presence: any(named: 'presence'),
messagesPagination: beforePagination,
membersPagination: any(named: 'membersPagination'),
watchersPagination: any(named: 'watchersPagination'),
preferOffline: any(named: 'preferOffline'),
)).called(1);
verify(() => mockChannel.query(
state: any(named: 'state'),
watch: any(named: 'watch'),
presence: any(named: 'presence'),
messagesPagination: afterPagination,
messagesPagination: paginationParams,
membersPagination: any(named: 'membersPagination'),
watchersPagination: any(named: 'watchersPagination'),
preferOffline: any(named: 'preferOffline'),
@@ -285,29 +259,15 @@ void main() {
_stateSetter?.call(() => initialMessageId = 'testInitialMessageId2');
final updatedBeforePagination = beforePagination.copyWith(
lessThan: initialMessageId,
);
final updatedAfterPagination = afterPagination.copyWith(
greaterThanOrEqual: initialMessageId,
final updatedPaginationParams = paginationParams.copyWith(
idAround: initialMessageId,
);
when(() => mockChannel.query(
state: any(named: 'state'),
watch: any(named: 'watch'),
presence: any(named: 'presence'),
messagesPagination: updatedBeforePagination,
membersPagination: any(named: 'membersPagination'),
watchersPagination: any(named: 'watchersPagination'),
preferOffline: any(named: 'preferOffline'),
)).thenAnswer((_) async => ChannelState(messages: messages));
when(() => mockChannel.query(
state: any(named: 'state'),
watch: any(named: 'watch'),
presence: any(named: 'presence'),
messagesPagination: updatedAfterPagination,
messagesPagination: updatedPaginationParams,
membersPagination: any(named: 'membersPagination'),
watchersPagination: any(named: 'watchersPagination'),
preferOffline: any(named: 'preferOffline'),
@@ -319,17 +279,7 @@ void main() {
state: any(named: 'state'),
watch: any(named: 'watch'),
presence: any(named: 'presence'),
messagesPagination: updatedBeforePagination,
membersPagination: any(named: 'membersPagination'),
watchersPagination: any(named: 'watchersPagination'),
preferOffline: any(named: 'preferOffline'),
)).called(1);
verify(() => mockChannel.query(
state: any(named: 'state'),
watch: any(named: 'watch'),
presence: any(named: 'presence'),
messagesPagination: updatedAfterPagination,
messagesPagination: updatedPaginationParams,
membersPagination: any(named: 'membersPagination'),
watchersPagination: any(named: 'watchersPagination'),
preferOffline: any(named: 'preferOffline'),
@@ -496,7 +496,7 @@ void main() {
_stateSetter?.call(() => limit = 6);
final updatedUsers = _generateUsers(count: limit);
final updatedPagination = pagination.copyWith(limit: limit);
final updatedPagination = PaginationParams(limit: limit);
when(() => mockClient.queryUsers(
filter: any(named: 'filter'),
sort: any(named: 'sort'),