-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix loading feedback when rating is null (#1380)
- Loading branch information
1 parent
f07dfac
commit 184c8cd
Showing
3 changed files
with
65 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
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,63 @@ | ||
// Copyright (c) 2022 Sharezone UG (haftungsbeschränkt) | ||
// Licensed under the EUPL-1.2-or-later. | ||
// | ||
// You may obtain a copy of the Licence at: | ||
// https://joinup.ec.europa.eu/software/page/eupl | ||
// | ||
// SPDX-License-Identifier: EUPL-1.2 | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:sharezone/feedback/history/feedback_view.dart'; | ||
import 'package:sharezone/feedback/src/models/user_feedback.dart'; | ||
|
||
void main() { | ||
group(FeedbackView, () { | ||
test('.fromUserFeedback() empty', () { | ||
final feedback = UserFeedback.create(); | ||
final view = FeedbackView.fromUserFeedback(feedback); | ||
|
||
expect(view.rating, isNull); | ||
expect(view.likes, ''); | ||
expect(view.dislikes, ''); | ||
expect(view.heardFrom, ''); | ||
expect(view.missing, ''); | ||
expect(view.createdOn, isNull); | ||
}); | ||
|
||
test('.fromUserFeedback() with data', () { | ||
final feedback = UserFeedback.create().copyWith( | ||
rating: 5.0, | ||
dislikes: 'd', | ||
heardFrom: 'h', | ||
likes: 'l', | ||
missing: 'm', | ||
); | ||
final view = FeedbackView.fromUserFeedback(feedback); | ||
|
||
expect(view.rating, '5.0/5.0'); | ||
expect(view.likes, 'l'); | ||
expect(view.dislikes, 'd'); | ||
expect(view.heardFrom, 'h'); | ||
expect(view.missing, 'm'); | ||
expect(view.createdOn, isNull); | ||
}); | ||
|
||
test('.hasX returns null even it is empty', () { | ||
const view = FeedbackView( | ||
createdOn: '', | ||
rating: '', | ||
likes: '', | ||
dislikes: '', | ||
heardFrom: '', | ||
missing: '', | ||
); | ||
|
||
expect(view.hasCreatedOn, isFalse); | ||
expect(view.hasRating, isFalse); | ||
expect(view.hasLikes, isFalse); | ||
expect(view.hasDislikes, isFalse); | ||
expect(view.hasHeardFrom, isFalse); | ||
expect(view.hasMissing, isFalse); | ||
}); | ||
}); | ||
} |