parent
0d972b3126
commit
7dc6dd5e1b
@ -0,0 +1,25 @@ |
||||
import 'package:flutter_test/flutter_test.dart'; |
||||
import 'package:mobx/mobx.dart'; |
||||
import 'package:mobx/src/api/async.dart'; |
||||
import 'package:thesis_shop/models/product.dart'; |
||||
import 'package:thesis_shop/stores/cart_store.dart'; |
||||
import 'package:thesis_shop/stores/product_store.dart'; |
||||
|
||||
import 'product_service_mock.dart'; |
||||
|
||||
class MockedProductStore implements ProductStore { |
||||
@override |
||||
void loadProducts() {} |
||||
|
||||
@override |
||||
ObservableFuture<List<Product>> products = |
||||
ObservableFuture.value(demoProducts); |
||||
} |
||||
|
||||
void main() { |
||||
test('test cart store', () { |
||||
final cartStore = CartStore(MockedProductStore()); |
||||
cartStore.incrementAmountOfProduct(demoProducts.first); |
||||
expect(cartStore.amountOfProduct(demoProducts.first), 1); |
||||
}); |
||||
} |
@ -0,0 +1,55 @@ |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_test/flutter_test.dart'; |
||||
import 'package:mobx/src/api/observable_collections.dart'; |
||||
import 'package:thesis_shop/models/cart_item.dart'; |
||||
import 'package:thesis_shop/models/product.dart'; |
||||
import 'package:thesis_shop/screens/cart/total_price_text.dart'; |
||||
import 'package:thesis_shop/stores/cart_item_store.dart'; |
||||
import 'package:thesis_shop/stores/cart_store.dart'; |
||||
import 'package:thesis_shop/stores/store_injector.dart'; |
||||
import 'package:thesis_shop/stores/user_store.dart'; |
||||
|
||||
import 'cart_store_test.dart'; |
||||
|
||||
class MockedCartStore implements CartStore { |
||||
@override |
||||
int amountOfProduct(Product product) { |
||||
throw UnimplementedError(); |
||||
} |
||||
|
||||
@override |
||||
ObservableList<CartItem> get cart => throw UnimplementedError(); |
||||
|
||||
@override |
||||
CartItemStore cartItemStoreOfProduct(Product product) { |
||||
throw UnimplementedError(); |
||||
} |
||||
|
||||
@override |
||||
void decrementAmountOfProduct(Product product) {} |
||||
|
||||
@override |
||||
void incrementAmountOfProduct(Product product) {} |
||||
|
||||
@override |
||||
int get numberOfItems => throw UnimplementedError(); |
||||
|
||||
@override |
||||
double get totalPrice => 10.0; |
||||
} |
||||
|
||||
void main() { |
||||
testWidgets('test total price text', (tester) async { |
||||
await tester.pumpWidget( |
||||
StoreInjector( |
||||
userStore: UserStore(), |
||||
cartStore: MockedCartStore(), |
||||
productStore: MockedProductStore(), |
||||
child: const MaterialApp( |
||||
home: TotalPriceText(), |
||||
), |
||||
), |
||||
); |
||||
expect(find.text('Gesamtpreis: 10.00€'), findsOneWidget); |
||||
}); |
||||
} |
Loading…
Reference in new issue