initial commit (migrated)
This commit is contained in:
commit
b594facb51
143 changed files with 11057 additions and 0 deletions
34
test/features/quote/domain/use_cases/get_quote_test.dart
Normal file
34
test/features/quote/domain/use_cases/get_quote_test.dart
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:kuwot/features/quote/domain/entities/quote.dart';
|
||||
import 'package:kuwot/features/quote/domain/repositories/quote_repository.dart';
|
||||
import 'package:kuwot/features/quote/domain/use_cases/get_quote.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
|
||||
class MockQuoteRepository extends Mock implements QuoteRepository {}
|
||||
|
||||
void main() {
|
||||
late MockQuoteRepository mockQuoteRepository;
|
||||
late GetQuote useCase;
|
||||
|
||||
setUp(() {
|
||||
mockQuoteRepository = MockQuoteRepository();
|
||||
useCase = GetQuote(mockQuoteRepository);
|
||||
});
|
||||
|
||||
test('should get quote', () async {
|
||||
// arrange
|
||||
const tQuote = Quote(id: 1, author: 'author', body: 'text');
|
||||
when(
|
||||
() => mockQuoteRepository.getQuote(any()),
|
||||
).thenAnswer((_) async => right(tQuote));
|
||||
|
||||
// act
|
||||
final result = await useCase(const GetQuoteParams(null));
|
||||
|
||||
// assert
|
||||
expect(result, right(tQuote));
|
||||
verify(() => mockQuoteRepository.getQuote(any()));
|
||||
verifyNoMoreInteractions(mockQuoteRepository);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue