Mercurial > public > simoleon
diff Simoleon/Favorites.swift @ 93:529feb1fc8d5
Added UI Tests for capture screenshots
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Tue, 03 Aug 2021 12:33:32 +0100 |
parents | 98852b65438c |
children | 04feeb708833 |
line wrap: on
line diff
--- a/Simoleon/Favorites.swift Tue Aug 03 10:10:14 2021 +0100 +++ b/Simoleon/Favorites.swift Tue Aug 03 12:33:32 2021 +0100 @@ -46,6 +46,7 @@ .if(UIDevice.current.userInterfaceIdiom == .phone) { content in NavigationView { content } } + .onAppear(perform: generateFavoritesToScreenshots) } private func removeFromFavorites(offsets: IndexSet) { @@ -60,11 +61,34 @@ } } } + + private func generateFavoritesToScreenshots() { + #if DEBUG + if favorite.isEmpty { + let favoriteCurrencies = [ + "EUR/USD", "BTC/USD", "USD/HKD", "USD/JPY", "AUD/USD", "XAU/GBP", "DASH/ETH", "EUR/USD", + "XAG/CAD", "XRP/RUB" + ] + + for favoriteCurrency in favoriteCurrencies { + let favorite = Favorite(context: viewContext) + favorite.currencyPair = favoriteCurrency + + do { + try viewContext.save() + } catch { + let nsError = error as NSError + fatalError("Unresolved error \(nsError), \(nsError.userInfo)") + } + } + } + #endif + } } struct Favorites_Previews: PreviewProvider { static var previews: some View { Favorites() -// .environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) + .environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) } }