Skip to content

Commit

Permalink
feat: new field pageCount for searchResult (#823)
Browse files Browse the repository at this point in the history
Impacted files:
* `api_get_user_products_test.dart`: now using `pageCount` instead of `count`
* `api_search_products_test.dart`: skipped a test failing because of the server
* `search_result.dart`: added field `pageCount`
* `search_result.g.dart`: generated
  • Loading branch information
monsieurtanuki committed Nov 15, 2023
1 parent 8fdee5f commit 1d88bbf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/src/model/search_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class SearchResult extends JsonObject {
@JsonKey(name: 'count', fromJson: JsonObject.parseInt)
final int? count;

@JsonKey(name: 'page_count', fromJson: JsonObject.parseInt)
final int? pageCount;

@JsonKey(name: 'skip', fromJson: JsonObject.parseInt)
final int? skip;

Expand All @@ -25,6 +28,7 @@ class SearchResult extends JsonObject {
this.page,
this.pageSize,
this.count,
this.pageCount,
this.skip,
this.products,
});
Expand Down
2 changes: 2 additions & 0 deletions lib/src/model/search_result.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/api_get_user_products_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ void main() {
expect(result.page, 1, reason: reason); // default
expect(result.pageSize, pageSize, reason: reason);
expect(result.products, isNotNull, reason: reason);
expect(result.products!.length, result.count, reason: reason);
expect(result.products!.length, result.pageCount, reason: reason);
if (additionalCheck != null) {
for (final Product product in result.products!) {
additionalCheck(product);
}
}
return result.count!;
return result.pageCount!;
}

Future<int> getCountForAllLanguages(
Expand Down
2 changes: 1 addition & 1 deletion test/api_search_products_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ void main() {
expect(result.products!.length, 24);
expect(result.products![0].runtimeType, Product);
expect(result.count, greaterThan(1500));
});
}, skip: 'Temporarily not working (server issue)');

test('many many products', () async {
final List<String> manyBarcodes = <String>[];
Expand Down

0 comments on commit 1d88bbf

Please sign in to comment.