parent
3e86e27e7d
commit
d4f4822809
@ -0,0 +1,19 @@ |
||||
import 'dart:async'; |
||||
|
||||
import 'package:flutter_test/flutter_test.dart'; |
||||
import 'package:thesis_shop/models/remote_resource.dart'; |
||||
import 'package:thesis_shop/store/cart_store.dart'; |
||||
|
||||
import 'product_service_mock.dart'; |
||||
|
||||
void main() { |
||||
test('test cart store', () async { |
||||
final cartStore = CartStore(); |
||||
cartStore.updateProductList(const RemoteResource.finished(demoProducts)); |
||||
final callbackStream = StreamController(); |
||||
cartStore.addListener(() => callbackStream.add(true)); |
||||
cartStore.increaseAmount(demoProducts.first); |
||||
expect(cartStore.amountOfProduct(demoProducts.first), 1); |
||||
await expectLater(callbackStream.stream, emits(true)); |
||||
}); |
||||
} |
@ -0,0 +1,26 @@ |
||||
// ignore_for_file: unnecessary_cast |
||||
|
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_test/flutter_test.dart'; |
||||
import 'package:provider/provider.dart'; |
||||
import 'package:thesis_shop/screens/cart/total_price_text.dart'; |
||||
import 'package:thesis_shop/store/cart_store.dart'; |
||||
|
||||
class CartStoreMock extends CartStore { |
||||
@override |
||||
double get totalPrice => 10.0; |
||||
} |
||||
|
||||
void main() { |
||||
testWidgets('test total price', (tester) async { |
||||
final widgetTree = MaterialApp( |
||||
home: ChangeNotifierProvider.value( |
||||
value: CartStoreMock() as CartStore, |
||||
child: const TotalPriceText(), |
||||
), |
||||
); |
||||
await tester.pumpWidget(widgetTree); |
||||
final correctText = find.text("Gesamtpreis: 10.00€"); |
||||
expect(correctText, findsOneWidget); |
||||
}); |
||||
} |
Loading…
Reference in new issue