import { Injectable } from "@angular/core" ; import { Keyboard } from "@ionic-native/keyboard/ngx" ; import { Network } from "@ionic-native/network/ngx" ; import { QRScanner , QRScannerStatus } from "@ionic-native/qr-scanner/ngx" ; import { ScreenOrientation } from "@ionic-native/screen-orientation/ngx" ; import { SocialSharing } from "@ionic-native/social-sharing/ngx" ; import { SplashScreen } from "@ionic-native/splash-screen/ngx" ; import { StatusBar } from "@ionic-native/status-bar/ngx" ; import { Delegate , Network as ArkNetwork } from "ark-ts" ; import { Observable , of , Subject } from "rxjs" ; import { Profile , StoredNetwork , Wallet , WalletKeys } from "@/models/model" ; import { UserDataService } from "@/services/user-data/user-data.interface" ; @ Injectable ( ) export class SplashScreenMock extends SplashScreen { show ( ) { } hide ( ) { } } @ Injectable ( ) export class StatusBarMock extends StatusBar { isVisible : boolean ; overlaysWebView ( doesOverlay ) { } styleDefault ( ) { } styleLightContent ( ) { } styleBlackTranslucent ( ) { } styleBlackOpaque ( ) { } backgroundColorByName ( colorName ) { } backgroundColorByHexString ( hexString ) { } hide ( ) { } show ( ) { } } @ Injectable ( ) export class QRScannerMock extends QRScanner { prepare ( ) { return Promise . resolve ( undefined ) ; } scan ( ) { return new Observable ( ( observer ) => { observer . next ( "" ) ; observer . complete ( ) ; } ) ; } show ( ) { return Promise . resolve ( undefined ) ; } hide ( ) { return Promise . resolve ( undefined ) ; } openSettings ( ) { } } @ Injectable ( ) export class KeyboardMock extends Keyboard { hideKeyboardAccessoryBar ( hide ) { } show ( ) { } close ( ) { } disableScroll ( disable ) { } onKeyboardShow ( ) { return new Observable ( ( observer ) => { observer . next ( "" ) ; observer . complete ( ) ; } ) ; } onKeyboardHide ( ) { return new Observable ( ( observer ) => { observer . next ( "" ) ; observer . complete ( ) ; } ) ; } } @ Injectable ( ) export class NetworkMock extends Network { type = "cellular" ; downlinkMax : string ; onchange ( ) { return new Observable ( ( observer ) => { observer . next ( "" ) ; observer . complete ( ) ; } ) ; } onDisconnect ( ) { return new Observable ( ( observer ) => { observer . next ( "" ) ; observer . complete ( ) ; } ) ; } onConnect ( ) { return new Observable ( ( observer ) => { observer . next ( "" ) ; observer . complete ( ) ; } ) ; } } @ Injectable ( ) export class SocialSharingMock extends SocialSharing { share ( message ? , subject ? , file ? , url ? ) { return Promise . resolve ( ) ; } } @ Injectable ( ) export class ScreenOrientationMock extends ScreenOrientation { type : string ; ORIENTATIONS : { PORTRAIT_PRIMARY : string ; PORTRAIT_SECONDARY : string ; LANDSCAPE_PRIMARY : string ; LANDSCAPE_SECONDARY : string ; PORTRAIT : string ; LANDSCAPE : string ; ANY : string ; } ; onChange ( ) { return new Observable ( ( observer ) => { observer . complete ( ) ; } ) ; } lock ( orientation ) { return new Promise ( ( resolve , reject ) => { resolve ( ) ; } ) ; } unlock ( ) { } } const generateMockProfile = ( ) => { const userProfile = new Profile ( ) ; userProfile . contacts = [ ] ; userProfile . name = "Test profile" ; userProfile . networkId = "30" ; userProfile . wallets = [ ] ; return userProfile ; } ; @ Injectable ( ) export class UserDataProviderMock implements UserDataService { public currentNetwork : StoredNetwork ; public currentWallet : Wallet ; public currentProfile : Profile ; public profiles : Record < string , Profile > ; public networks : Record < string , StoredNetwork > ; public onActivateNetwork$ : Subject < StoredNetwork > ; public onUpdateNetwork$ : Subject < StoredNetwork > ; public onCreateWallet$ : Subject < Wallet > ; public onUpdateWallet$ : Subject < Wallet > ; public onSelectProfile$ : Subject < Profile > ; constructor ( ) { const mockProfile = generateMockProfile ( ) ; this . profiles = { [ "test_profile_id" ] : mockProfile } ; this . currentProfile = mockProfile ; } public get isDevNet ( ) : boolean { throw new Error ( "Method not implemented." ) ; } public get isMainNet ( ) : boolean { throw new Error ( "Method not implemented." ) ; } public get defaultNetworks ( ) : ArkNetwork [ ] { throw new Error ( "Method not implemented." ) ; } public addOrUpdateNetwork ( network , networkId ? ) { throw new Error ( "Method not implemented." ) ; } public getNetworkById ( networkId ) { throw new Error ( "Method not implemented." ) ; } public removeNetworkById ( networkId ) { throw new Error ( "Method not implemented." ) ; } public addProfile ( profile ) { throw new Error ( "Method not implemented." ) ; } public getProfileByName ( name ) { throw new Error ( "Method not implemented." ) ; } public getProfileById ( profileId ) { throw new Error ( "Method not implemented." ) ; } public removeProfileById ( profileId ) { throw new Error ( "Method not implemented." ) ; } public saveProfiles ( profiles ? ) { if ( profiles ) { this . profiles = profiles ; } return of ( true ) ; } public setCurrentProfile ( profileId , broadcast = true ) { this . currentProfile = this . profiles [ profileId ] ; } public encryptSecondPassphrase ( wallet , pinCode , secondPassphrase , profileId ? ) { throw new Error ( "Method not implemented." ) ; } public addWallet ( wallet , passphrase , pinCode , profileId ? ) { throw new Error ( "Method not implemented." ) ; } public updateWalletEncryption ( oldPassword , newPassword ) { throw new Error ( "Method not implemented." ) ; } public removeWalletByAddress ( address , profileId ? ) { throw new Error ( "Method not implemented." ) ; } public ensureWalletDelegateProperties ( wallet , delegateOrUserName ) { throw new Error ( "Method not implemented." ) ; } public getWalletByAddress ( address , profileId ? ) { throw new Error ( "Method not implemented." ) ; } public updateWallet ( wallet , profileId , notificate ? ) { throw new Error ( "Method not implemented." ) ; } public saveWallet ( wallet , profileId ? , notificate ? ) { throw new Error ( "Method not implemented." ) ; } public setWalletLabel ( wallet , label ) { throw new Error ( "Method not implemented." ) ; } public getWalletLabel ( walletOrAddress , profileId ? ) { throw new Error ( "Method not implemented." ) ; } public setCurrentWallet ( wallet ) { throw new Error ( "Method not implemented." ) ; } public clearCurrentWallet ( ) { throw new Error ( "Method not implemented." ) ; } public loadProfiles ( ) { throw new Error ( "Method not implemented." ) ; } public loadNetworks ( ) { throw new Error ( "Method not implemented." ) ; } public getKeysByWallet ( wallet , password ) { throw new Error ( "Method not implemented." ) ; } }