forked from eatvio/eatvio_app
feat(tests): test coverage is 70.5
This commit is contained in:
@@ -105,5 +105,14 @@ void main() {
|
||||
final result = await cubit.executeFailingOperationWithState();
|
||||
expect(result, isNull);
|
||||
});
|
||||
|
||||
test('handleError logs error without throwing', () {
|
||||
expect(() => cubit.handleError(Exception('Test error')), returnsNormally);
|
||||
});
|
||||
|
||||
test('handleError logs error with stack trace', () {
|
||||
final stackTrace = StackTrace.current;
|
||||
expect(() => cubit.handleError(Exception('Test error'), stackTrace), returnsNormally);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -26,5 +26,18 @@ void main() {
|
||||
// Const instances should be equal
|
||||
expect(state1, state2);
|
||||
});
|
||||
|
||||
test('MarketingCubitState can be used in equality checks', () {
|
||||
const state1 = MarketingCubitState();
|
||||
const state2 = MarketingCubitState();
|
||||
|
||||
expect(state1 == state2, true);
|
||||
expect(state1.hashCode, state2.hashCode);
|
||||
});
|
||||
|
||||
test('MarketingCubitState toString returns correct representation', () {
|
||||
const state = MarketingCubitState();
|
||||
expect(state.toString(), contains('MarketingCubitState'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,6 +59,35 @@ void main() {
|
||||
expect(StateUtils.getErrorMessage('error: test'), isNotNull);
|
||||
expect(StateUtils.getErrorMessage('Error: test message'), isNotNull);
|
||||
});
|
||||
|
||||
test('getErrorMessage extracts error message from complex state string', () {
|
||||
const errorState = 'StateError(error: Network error occurred)';
|
||||
final message = StateUtils.getErrorMessage(errorState);
|
||||
expect(message, isNotNull);
|
||||
expect(message, contains('Network'));
|
||||
});
|
||||
|
||||
test('getErrorMessage returns null for empty error state', () {
|
||||
expect(StateUtils.getErrorMessage(''), isNull);
|
||||
});
|
||||
|
||||
test('isLoading handles case variations', () {
|
||||
expect(StateUtils.isLoading('isLoading'), isTrue);
|
||||
expect(StateUtils.isLoading('state_is_loading'), isTrue);
|
||||
expect(StateUtils.isLoading('StateLoading'), isTrue);
|
||||
});
|
||||
|
||||
test('isLoaded handles case variations', () {
|
||||
expect(StateUtils.isLoaded('isLoaded'), isTrue);
|
||||
expect(StateUtils.isLoaded('state_is_loaded'), isTrue);
|
||||
expect(StateUtils.isLoaded('StateLoaded'), isTrue);
|
||||
});
|
||||
|
||||
test('isError handles case variations', () {
|
||||
expect(StateUtils.isError('isError'), isTrue);
|
||||
expect(StateUtils.isError('state_is_error'), isTrue);
|
||||
expect(StateUtils.isError('StateError'), isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user