diff --git a/package.json b/package.json index 8ce1dd9..a317f31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ionic-native-mocks", - "version": "2.0.1", + "version": "2.0.3", "description": "Mocks for Ionic Native for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support", "homepage": "https://ionicframework.com/", "author": "Chris Griffith (https://aj-sofwtare.com)", diff --git a/src/@ionic-native-mocks/plugins/market/index.ts b/src/@ionic-native-mocks/plugins/market/index.ts new file mode 100644 index 0000000..2988109 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/market/index.ts @@ -0,0 +1,24 @@ +import { Market } from '@ionic-native/market'; + +export class MarketMock extends Market { + /** + * Opens an app in Google Play / App Store + * @param appId {string} Package name + * @return {Promise} + */ + open(appId: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Search apps by keyword + * @param keyword {string} Keyword + * @return {Promise} + */ + search(keyword: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/media-capture/index.ts b/src/@ionic-native-mocks/plugins/media-capture/index.ts new file mode 100644 index 0000000..bac2cb5 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/media-capture/index.ts @@ -0,0 +1,175 @@ +import { MediaCapture } from '@ionic-native/media-capture'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export interface MediaFile { + /** + * The name of the file, without path information. + */ + name: string; + /** + * The full path of the file, including the name. + */ + fullPath: string; + /** + * The file's mime type + */ + type: string; + /** + * The date and time when the file was last modified. + */ + lastModifiedDate: Date; + /** + * The size of the file, in bytes. + */ + size: number; + /** + * Retrieves the format information of the media file. + * @param {Function} successCallback + * @param {Function} errorCallback + */ + getFormatData(successCallback: (data: MediaFileData) => any, errorCallback?: (err: any) => any): void; +} +export interface MediaFileData { + /** + * The actual format of the audio and video content. + */ + codecs: string; + /** + * The average bitrate of the content. The value is zero for images. + */ + bitrate: number; + /** + * The height of the image or video in pixels. The value is zero for audio clips. + */ + height: number; + /** + * The width of the image or video in pixels. The value is zero for audio clips. + */ + width: number; + /** + * The length of the video or sound clip in seconds. The value is zero for images. + */ + duration: number; +} +export interface CaptureError { + code: string; +} +export interface CaptureAudioOptions { + /** + * Maximum number of audio clips. Defaults to 1. + * On iOS you can only record one file. + */ + limit?: number; + /** + * Maximum duration of an audio sound clip, in seconds. This does not work on Android devices. + */ + duration?: number; +} +export interface CaptureImageOptions { + /** + * Maximum number of images to capture. This limit is not supported on iOS, only one image will be taken per invocation. + */ + limit?: number; +} +export interface CaptureVideoOptions { + /** + * Maximum number of video clips to record. This value is ignored on iOS, only one video clip can be taken per invocation. + */ + limit?: number; + /** + * Maximum duration per video clip. This will be ignored on BlackBerry. + */ + duration?: number; + /** + * Quality of the video. This parameter can only be used with Android. + */ + quality?: number; +} +export interface ConfigurationData { + /** + * The ASCII-encoded lowercase string representing the media type. + */ + type: string; + /** + * The height of the image or video in pixels. The value is zero for sound clips. + */ + height: number; + /** + * The width of the image or video in pixels. The value is zero for sound clips. + */ + width: number; +} + +export class MediaCaptureMock extends MediaCapture { + /** + * The recording image sizes and formats supported by the device. + * @returns {ConfigurationData[]} + */ + supportedImageModes: ConfigurationData[]; + /** + * The audio recording formats supported by the device. + * @returns {ConfigurationData[]} + */ + supportedAudioModes: ConfigurationData[]; + /** + * The recording video resolutions and formats supported by the device. + * @returns {ConfigurationData[]} + */ + supportedVideoModes: ConfigurationData[]; + /** + * Start the audio recorder application and return information about captured audio clip files. + * @param options + * @returns {Promise} + */ + captureAudio(options?: CaptureAudioOptions): Promise { + let response: Array = []; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Start the camera application and return information about captured image files. + * @param options + * @returns {Promise} + */ + captureImage(options?: CaptureImageOptions): Promise { + let response: Array = []; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Start the video recorder application and return information about captured video clip files. + * @param options + * @returns {Promise} + */ + captureVideo(options?: CaptureVideoOptions): Promise { + let response: Array = []; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * is fired if the capture call is successful + * @returns {Observable} + */ + onPendingCaptureResult(): Observable { + let response: Array = []; + return Observable.create((observer: Observer) => { + observer.next(response); + observer.complete(); + }); + }; + /** + * is fired if the capture call is unsuccessful + * @returns {Observable} + */ + onPendingCaptureError(): Observable { + let response: Array = []; + return Observable.create((observer: Observer) => { + observer.next(response); + observer.complete(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/mixpanel/index.ts b/src/@ionic-native-mocks/plugins/mixpanel/index.ts new file mode 100644 index 0000000..7172ea4 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/mixpanel/index.ts @@ -0,0 +1,147 @@ +import { Mixpanel, MixpanelPeople } from '@ionic-native/mixpanel'; + +export class MixpanelMock extends Mixpanel { + /** + * + * @param aliasId {string} + * @param originalId {string} + * @returns {Promise} + */ + alias(aliasId: string, originalId: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * + * @returns {Promise} + */ + distinctId(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * @returns {Promise} + */ + flush(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * + * @param distinctId {string} + * @returns {Promise} + */ + identify(distinctId: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * + * @param token {string} + * @returns {Promise} + */ + init(token: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * + * @param superProperties {any} + * @returns {Promise} + */ + registerSuperProperties(superProperties: any): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * + * @returns {Promise} + */ + reset(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * + * @param eventName {string} + * @returns {Promise} + */ + timeEvent(eventName: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * + * @param eventName {string} + * @param eventProperties {any} optional + * @returns {Promise} + */ + track(eventName: string, eventProperties?: any): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} +/** + * @hidden + */ +export class MixpanelPeopleMock extends MixpanelPeople { + /** + * + * @param distinctId {string} + * @return {Promise} + */ + identify(distinctId: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * + * @param peopleProperties {string} + * @return {Promise} + */ + increment(peopleProperties: any): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * + * @param pushId + * @return {Promise} + */ + setPushId(pushId: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * + * @param peopleProperties + * @return {Promise} + */ + set(peopleProperties: any): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * + * @param peopleProperties + * @return {Promise} + */ + setOnce(peopleProperties: any): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/mobile-accessibility/index.ts b/src/@ionic-native-mocks/plugins/mobile-accessibility/index.ts new file mode 100644 index 0000000..5b3191d --- /dev/null +++ b/src/@ionic-native-mocks/plugins/mobile-accessibility/index.ts @@ -0,0 +1,241 @@ +import { MobileAccessibility } from '@ionic-native/mobile-accessibility'; + +export class MobileAccessibilityMock extends MobileAccessibility { + MobileAccessibilityNotifications: { + ANNOUNCEMENT: 'ANNOUNCEMENT'; + BOLD_TEXT_STATUS_CHANGED: 'BOLD_TEXT_STATUS_CHANGED'; + CLOSED_CAPTIONING_STATUS_CHANGED: 'CLOSED_CAPTIONING_STATUS_CHANGED'; + DARKER_SYSTEM_COLORS_STATUS_CHANGED: 'DARKER_SYSTEM_COLORS_STATUS_CHANGED'; + GRAYSCALE_STATUS_CHANGED: 'GRAYSCALE_STATUS_CHANGED'; + GUIDED_ACCESS_STATUS_CHANGED: 'GUIDED_ACCESS_STATUS_CHANGED'; + INVERT_COLORS_STATUS_CHANGED: 'INVERT_COLORS_STATUS_CHANGED'; + LAYOUT_CHANGED: 'LAYOUT_CHANGED'; + MONO_AUDIO_STATUS_CHANGED: 'MONO_AUDIO_STATUS_CHANGED'; + PAGE_SCROLLED: 'PAGE_SCROLLED'; + REDUCE_MOTION_STATUS_CHANGED: 'REDUCE_MOTION_STATUS_CHANGED'; + REDUCE_TRANSPARENCY_STATUS_CHANGED: 'REDUCE_TRANSPARENCY_STATUS_CHANGED'; + SCREEN_CHANGED: 'SCREEN_CHANGED'; + SCREEN_READER_STATUS_CHANGED: 'SCREEN_READER_STATUS_CHANGED'; + SPEAK_SCREEN_STATUS_CHANGED: 'SPEAK_SCREEN_STATUS_CHANGED'; + SPEAK_SELECTION_STATUS_CHANGED: 'SPEAK_SELECTION_STATUS_CHANGED'; + SWITCH_CONTROL_STATUS_CHANGED: 'SWITCH_CONTROL_STATUS_CHANGED'; + TOUCH_EXPLORATION_STATUS_CHANGED: 'TOUCH_EXPLORATION_STATUS_CHANGED'; + }; + /** + * Makes an asynchronous call to native MobileAccessibility to determine if a screen reader is running. + * @returns {Promise} A result method to receive the boolean result asynchronously from the native MobileAccessibility plugin. + */ + isScreenReaderRunning(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * An iOS-specific proxy for the MobileAccessibility.isScreenReaderRunning method + * @returns {Promise} A result method to receive the boolean result asynchronously from the native MobileAccessibility plugin. + */ + isVoiceOverRunningCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * An Android/Amazon Fire OS-specific proxy for the MobileAccessibility.isScreenReaderRunning method. + * @returns {Promise} A result method to receive the boolean result asynchronously from the native MobileAccessibility plugin. + */ + isTalkBackRunningCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * On Android, this method returns true if ChromeVox is active and properly initialized with access to the text to speech API in the WebView. + * If TalkBack is running but ChromeVox is not active, this method is useful to alert the user of a potential problem. + * @returns {Promise} Returns the result + */ + isChromeVoxActive(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isBoldTextEnabledCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isClosedCaptioningEnabledCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isDarkerSystemColorsEnabledCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isGrayscaleEnabledCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isGuidedAccessEnabledCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isInvertColorsEnabledCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isMonoAudioEnabledCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isReduceMotionEnabledCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isReduceTransparencyEnabledCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isSpeakScreenEnabledCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isSpeakSelectionEnabledCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isSwitchControlRunningCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @returns {Promise} Returns the result + */ + isTouchExplorationEnabledCallback(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * * @returns {Promise} Returns the result + */ + getTextZoomCallback(): Promise { + let response: number; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * @param textZoom {number} A percentage value by which text in the WebView should be scaled. + */ + setTextZoom(textZoom: number): void {}; + /** + * + */ + updateTextZoom(): void {}; + /** + * A Boolean value which specifies whether to use the preferred text zoom of a default percent value of 100. + * @param value {boolean} Returns the result + */ + usePreferredTextZoom(value: boolean): void {}; + /** + * Posts a notification with a string for the screen reader to announce if it is running. + * @param mobileAccessibilityNotification {any} + * @param value {string} A string to be announced by a screen reader. + * @returns {Promise} Returns the result + */ + postNotification(mobileAccessibilityNotification: any, value: string): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Speaks a given string through the screenreader. On Android, if ChromeVox is active, it will use the specified queueMode and properties. + * @param value {string} + * @param queueMode {mumber} + * @param properties {any} + */ + speak(value: string, queueMode?: number, properties?: any): void {}; + /** + * Stops speech. + */ + stop(): void {}; +} diff --git a/src/@ionic-native-mocks/plugins/music-controls/index.ts b/src/@ionic-native-mocks/plugins/music-controls/index.ts new file mode 100644 index 0000000..b779ff2 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/music-controls/index.ts @@ -0,0 +1,73 @@ +import { MusicControls } from '@ionic-native/music-controls'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export interface MusicControlsOptions { + track: string; + artist: string; + cover: string; + isPlaying: boolean; + dismissable: boolean; + hasPrev: boolean; + hasNext: boolean; + hasClose: boolean; + album: string; + duration: number; + elapsed: number; + ticker: string; +} + +export class MusicControlsMocks extends MusicControls { + /** + * Create the media controls + * @param options {MusicControlsOptions} + * @returns {Promise} + */ + create(options: MusicControlsOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Destroy the media controller + * @returns {Promise} + */ + destroy(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Subscribe to the events of the media controller + * @returns {Observable} + */ + subscribe(): Observable { + let response: any; + return Observable.create((observer: Observer) => { + observer.next(response); + observer.complete(); + }); + }; + /** + * Start listening for events, this enables the Observable from the subscribe method + */ + listen(): void { }; + /** + * Toggle play/pause: + * @param isPlaying {boolean} + */ + updateIsPlaying(isPlaying: boolean): void { }; + /** + * Update elapsed time, optionally toggle play/pause: + * @param args {Object} + */ + updateElapsed(args: { + elapsed: string; + isPlaying: boolean; + }): void { }; + /** + * Toggle dismissable: + * @param dismissable {boolean} + */ + updateDismissable(dismissable: boolean): void { }; +} diff --git a/src/@ionic-native-mocks/plugins/native-audio/index.ts b/src/@ionic-native-mocks/plugins/native-audio/index.ts new file mode 100644 index 0000000..c057ed5 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/native-audio/index.ts @@ -0,0 +1,81 @@ +import { NativeAudio } from '@ionic-native/native-audio'; + +export class NativeAudioMock extends NativeAudio { + /** + * Loads an audio file into memory. Optimized for short clips / single shots (up to five seconds). Cannot be stopped / looped. + * @param id {string} unique ID for the audio file + * @param assetPath {string} the relative path or absolute URL (inluding http://) to the audio asset. + * @returns {Promise} + */ + preloadSimple(id: string, assetPath: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Loads an audio file into memory. Optimized for background music / ambient sound. Uses highlevel native APIs with a larger footprint. (iOS: AVAudioPlayer). Can be stopped / looped and used with multiple voices. Can be faded in and out using the delay parameter. + * @param id {string} unique ID for the audio file + * @param assetPath {string} the relative path or absolute URL (inluding http://) to the audio asset. + * @param volume {number} the volume of the preloaded sound (0.1 to 1.0) + * @param voices {number} the number of multichannel voices available + * @param delay {number} + * @returns {Promise} + */ + preloadComplex(id: string, assetPath: string, volume: number, voices: number, delay: number): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Plays an audio asset + * @param id {string} unique ID for the audio file + * @param completeCallback {Function} optional. Callback to be invoked when audio is done playing + * @returns {Promise} + */ + play(id: string, completeCallback?: Function): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Stops playing an audio + * @param id {string} unique ID for the audio file + * @returns {Promise} + */ + stop(id: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Loops an audio asset infinitely, this only works for complex assets + * @param id {string} unique ID for the audio file + * @return {Promise} + */ + loop(id: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Unloads an audio file from memory + * @param id {string} unique ID for the audio file + * @returns {Promise} + */ + unload(id: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Changes the volume for preloaded complex assets. + * @param id {string} unique ID for the audio file + * @param volume {number} the volume of the audio asset (0.1 to 1.0) + * @returns {Promise} + */ + setVolumeForComplexAsset(id: string, volume: number): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/native-geocoder/index.ts b/src/@ionic-native-mocks/plugins/native-geocoder/index.ts new file mode 100644 index 0000000..0eaa90a --- /dev/null +++ b/src/@ionic-native-mocks/plugins/native-geocoder/index.ts @@ -0,0 +1,73 @@ +import { NativeGeocoder } from '@ionic-native/native-geocoder'; + +export class NativeGeocoderMock extends NativeGeocoder { + /** + * Reverse geocode a given latitude and longitude to find location address + * @param latitude {number} The latitude + * @param longitude {number} The longitude + * @return {Promise} + */ + reverseGeocode(latitude: number, longitude: number): Promise { + let response: NativeGeocoderReverseResult; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Forward geocode a given address to find coordinates + * @param addressString {string} The address to be geocoded + * @return {Promise} + */ + forwardGeocode(addressString: string): Promise { + let response: NativeGeocoderForwardResult; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; +} +/** + * Encapsulates format information about a reverse geocoding result. + */ +export interface NativeGeocoderReverseResult { + /** + * The street. + */ + street: string; + /** + * The house number. + */ + houseNumber: string; + /** + * The postal code. + */ + postalCode: string; + /** + * The city. + */ + city: string; + /** + * The district. + */ + district: string; + /** + * The country name. + */ + countryName: string; + /** + * The country code. + */ + countryCode: string; +} +/** + * Encapsulates format information about a forward geocoding result. + */ +export interface NativeGeocoderForwardResult { + /** + * The latitude. + */ + latitude: string; + /** + * The longitude. + */ + longitude: string; +} diff --git a/src/@ionic-native-mocks/plugins/native-keyboard/index.ts b/src/@ionic-native-mocks/plugins/native-keyboard/index.ts new file mode 100644 index 0000000..c995999 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/native-keyboard/index.ts @@ -0,0 +1,181 @@ +import { NativeKeyboard } from '@ionic-native/native-keyboard'; + +export interface NativeKeyboardOptions { + /** + * A function invoked when the user submits his input. Receives the text as a single property. Make sure your page is UTF-8 encoded so Chinese and Emoji are rendered OK. + */ + onSubmit: Function; + /** + * A function invoked when the keyboard is about to pop up. Receives the height as a single property. (iOS only) + */ + onKeyboardWillShow: Function; + /** + * A function invoked when the keyboard popped up. Receives the height as a single property. + */ + onKeyboardDidShow: Function; + /** + * A function invoked when the keyboard is about to close. (iOS only) + */ + onKeyboardWillHide: Function; + /** + * A function invoked when the keyboard closed. + */ + onKeyboardDidHide: Function; + /** + * A function invoked when any key is pressed, sends the entire text as response. + */ + onTextChanged: Function; + /** + * Highly recommended to pass in if you want to replicate the behavior of the video's above (scroll down when the keyboard opens). Pass in the scrollable DOM element containing the messages. + */ + autoscrollElement: HTMLElement; + /** + * If `autoscrollElement` was set you can also make the list scroll down initially, when the messenger bar (without the keyboard popping up) is shown. + */ + scrollToBottomAfterMessengerShows: boolean; + /** + * Setting this to `true` is like the video's above: the keyboard doesn't close upon submit. Defaults to `false`. + */ + keepOpenAfterSubmit: boolean; + /** + * Makes the messenger bar slide in from the bottom. Defaults to `false`. + */ + animated: boolean; + /** + * Open the keyboard when showing the messenger. Defaults to `false`. + */ + showKeyboard: boolean; + /** + * The default text set in the messenger input bar. + */ + text: string; + /** + * The color of the typed text. Defaults to `#444444`. + */ + textColor: string; + /** + * Like a regular HTML input placeholder. + */ + placeholder: string; + /** + * The color of the placeholder text. Defaults to `#CCCCCC`. + */ + placeholderColor: string; + /** + * The background color of the messenger bar. Defaults to `#F6F6F6`. + */ + backgroundColor: string; + /** + * The background color of the textview. Looks nicest on Android if it's the same color as the `backgroundColor` property. Defaults to `#F6F6F6`. + */ + textViewBackgroundColor: string; + /** + * The border color of the textview. Defaults to `#666666`. (iOS only) + */ + textViewBorderColor: string; + /** + * Setting this > 0 will make a counter show up on iOS (and ignore superfluous input on Android, for now) + */ + maxChars: number; + /** + * Options are: `"none"`, `"split"`, `"countdown"`, `"countdownreversed"`. Note that if `maxChars` is set, `"none"` will still show a counter. Defaults to `"none"`. (iOS only) + */ + counterStyle: string; + /** + * Options are: "default", "decimalpad", "phonepad", "numberpad", "namephonepad", "number", "email", "twitter", "url", "alphabet", "search", "ascii". (iOS only) + */ + type: string; + /** + * Options are: "light", "dark". (iOS only) + */ + appearance: string; + /** + * Disables things like the Emoji keyboard and the Predicive text entry bar (iOS only) + */ + secure: boolean; + /** + * + */ + leftButton: NativeKeyboardLeftButton; + /** + * + */ + rightButton: NativeKeyboardButton; +} +export interface NativeKeyboardButton { + /** + * Either "text" (Android only currently), "fontawesome" or "ionicon". + */ + type: string; + /** + * Depends on the type. Examples: for "text" use "Send", for "fontawesome" use "fa-battery-quarter", for "ionicon" use "\uf48a" (go to http://ionicons.com, right-click and inspect the icon and use the value you find in :before). Note that some fonticons are not supported as the embedded fonts in the plugin may lag behind a little. So try one of the older icons first. + */ + value: string; + /** + * If type is "text" you can set this to either "normal", "bold" or "italic". + */ + textStyle: string; + /** + * A function invoked when the button is pressed. Use this button to prompt the user what he wants to do next by for instance rendering an ActionSheet. + */ + onPress: Function; +} +export interface NativeKeyboardLeftButton extends NativeKeyboardButton { + /** + * Set to `true` to disable the button once text has been entered. + */ + disabledWhenTextEntered: boolean; +} +export interface NativeKeyboardUpdateMessengerOptions { + /** + * Replace the messenger's text by this. The current text remains if omitted. + */ + text: string; + /** + * Position the cursor anywhere in the text range. Defaults to the end of the text. + */ + caretIndex: number; + /** + * If `false` or omitted no changes to the keyboard state are made. + */ + showKeyboard: boolean; +} + +export class NativeKeyboarMock extends NativeKeyboard { + /** + * Show messenger + * @param options {NativeKeyboardOptions} + */ + showMessenger(options: NativeKeyboardOptions): void {}; + /** + * Hide messenger + * @param options {NativeKeyboardOptions} + */ + hideMessenger(options: NativeKeyboardOptions): void {} ; + /** + * Programmatically pop up the keyboard again if the user dismissed it. + * @return {Promise} + */ + showMessengerKeyboard(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Programmatically hide the keyboard (but not the messenger bar) + */ + hideMessengerKeyboard(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Manipulate the messenger while it's open. For instance if you want to update the text programmatically based on what the user typed. + * @param options + */ + updateMessenger(options: NativeKeyboardUpdateMessengerOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/native-page-transitions/index.ts b/src/@ionic-native-mocks/plugins/native-page-transitions/index.ts new file mode 100644 index 0000000..6c8b018 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/native-page-transitions/index.ts @@ -0,0 +1,87 @@ +import { NativePageTransitions } from '@ionic-native/native-page-transitions'; + +export interface NativeTransitionOptions { + direction?: string; + duration?: number; + slowdownfactor?: number; + slidePixels?: number; + iosdelay?: number; + androiddelay?: number; + winphonedelay?: number; + fixedPixelsTop?: number; + fixedPixelsBottom?: number; + action?: string; + origin?: string; + href?: string; +} + +export class NativePageTransitionsMock extends NativePageTransitions { + /** + * Perform a slide animation + * @param options {NativeTransitionOptions} Options for the transition + * @returns {Promise} + */ + slide(options: NativeTransitionOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Perform a flip animation + * @param options {NativeTransitionOptions} Options for the transition + * @returns {Promise} + */ + flip(options: NativeTransitionOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Perform a fade animation + * @param options {NativeTransitionOptions} Options for the transition + * @returns {Promise} + */ + fade(options: NativeTransitionOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Perform a slide animation + * @param options {NativeTransitionOptions} Options for the transition + * @returns {Promise} + */ + drawer(options: NativeTransitionOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Perform a slide animation + * @param options {NativeTransitionOptions} Options for the transition + * @returns {Promise} + */ + curl(options: NativeTransitionOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Execute pending transition + * @returns {Promise} + */ + executePendingTransition(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Cancel pending transition + * @returns {Promise} + */ + cancelPendingTransition(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/native-ringtones/index.ts b/src/@ionic-native-mocks/plugins/native-ringtones/index.ts new file mode 100644 index 0000000..89252db --- /dev/null +++ b/src/@ionic-native-mocks/plugins/native-ringtones/index.ts @@ -0,0 +1,33 @@ +import { NativeRingtones } from '@ionic-native/native-ringtones'; + +export class NativeRingtonesMock extends NativeRingtones { + /** + * Get the ringtone list of the device + * @return {Promise} Returns a promise that resolves when ringtones found successfully + */ + getRingtone(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * This function starts playing the ringtone + * @param {string} ringtoneUri The path to the ringtone file + * @return {Promise} Returns a promise + */ + playRingtone(ringtoneUri: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * This function stops playing the ringtone + * @param {string} ringtoneUri The path to the ringtone file + * @return {Promise} Returns a promise + */ + stopRingtone(ringtoneUri: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/native-storage/index.ts b/src/@ionic-native-mocks/plugins/native-storage/index.ts new file mode 100644 index 0000000..c4283a1 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/native-storage/index.ts @@ -0,0 +1,53 @@ +import { NativeStorage } from '@ionic-native/native-storage'; + +export class NativeStorageMock extends NativeStorage { + /** + * Stores a value + * @param reference {string} + * @param value + * @returns {Promise} + */ + setItem(reference: string, value: any): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Gets a stored item + * @param reference {string} + * @returns {Promise} + */ + getItem(reference: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Retrieving all keys + * @returns {Promise} + */ + keys(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Removes a single stored item + * @param reference {string} + * @returns {Promise} + */ + remove(reference: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Removes all stored values. + * @returns {Promise} + */ + clear(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/navigation-bar/index.ts b/src/@ionic-native-mocks/plugins/navigation-bar/index.ts new file mode 100644 index 0000000..071cc06 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/navigation-bar/index.ts @@ -0,0 +1,23 @@ +import { NavigationBar } from '@ionic-native/navigation-bar'; + +export class NavigationBarMock extends NavigationBar { + /** + * hide automatically (or not) the navigation bar. + * @param autohide {boolean} + * @return {Promise} + */ + setUp(autohide?: boolean): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Hide the navigation bar. + * @return {Promise} + */ + hideNavigationBar(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/nfc/index.ts b/src/@ionic-native-mocks/plugins/nfc/index.ts new file mode 100644 index 0000000..e6e8d19 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/nfc/index.ts @@ -0,0 +1,179 @@ +import { NFC } from '@ionic-native/nfc'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export class NFCMock extends NFC { + /** + * Registers an event listener for any NDEF tag. + * @param onSuccess + * @param onFailure + * @returns {Observable} + */ + addNdefListener(onSuccess?: Function, onFailure?: Function): Observable { + return Observable.create((observer: Observer) => { + observer.next(''); + observer.complete(); + }); + }; + /** + * Registers an event listener for tags matching any tag type. + * @param onSuccess + * @param onFailure + * @returns {Observable} + */ + addTagDiscoveredListener(onSuccess?: Function, onFailure?: Function): Observable { + return Observable.create((observer: Observer) => { + observer.next(''); + observer.complete(); + }); + }; + /** + * Registers an event listener for NDEF tags matching a specified MIME type. + * @param mimeType + * @param onSuccess + * @param onFailure + * @returns {Observable} + */ + addMimeTypeListener(mimeType: string, onSuccess?: Function, onFailure?: Function): Observable { + return Observable.create((observer: Observer) => { + observer.next(''); + observer.complete(); + }); + }; + /** + * Registers an event listener for formatable NDEF tags. + * @param onSuccess + * @param onFailure + * @returns {Observable} + */ + addNdefFormatableListener(onSuccess?: Function, onFailure?: Function): Observable { + return Observable.create((observer: Observer) => { + observer.next(''); + observer.complete(); + }); + }; + /** + * Writes an NdefMessage(array of ndef records) to a NFC tag. + * @param message {any[]} + * @returns {Promise} + */ + write(message: any[]): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Makes a NFC tag read only. **Warning** this is permanent. + * @returns {Promise} + */ + makeReadyOnly(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Shares an NDEF Message(array of ndef records) via peer-to-peer. + * @param message An array of NDEF Records. + * @returns {Promise} + */ + share(message: any[]): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Stop sharing NDEF data via peer-to-peer. + * @returns {Promise} + */ + unshare(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Erase a NDEF tag + */ + erase(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Send a file to another device via NFC handover. + * @param uris A URI as a String, or an array of URIs. + * @returns {Promise} + */ + handover(uris: string[]): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Stop sharing NDEF data via NFC handover. + * @returns {Promise} + */ + stopHandover(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Opens the device's NFC settings. + * @returns {Promise} + */ + showSettings(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Check if NFC is available and enabled on this device. + * @returns {Promise} + */ + enabled(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * @{ NFC } class utility methods + * for use with + */ + /** + * Convert byte array to string + * @param bytes {number[]} + * @returns {string} + */ + bytesToString(bytes: number[]): string { + let response: string = ''; + return response; + }; + /** + * Convert string to byte array. + * @param str {string} + * @returns {number[]} + */ + stringToBytes(str: string): number[] { + let response: Array = []; + return response; + }; + /** + * Convert byte array to hex string + * + * @param bytes {number[]} + * @returns {string} + */ + bytesToHexString(bytes: number[]): string { + let response: string = ''; + return response; + }; +} +/** + * @hidden + */ +export class Ndef { + uriRecord(uri: string): any { return; }; + textRecord(text: string): any { return; }; + mimeMediaRecord(mimeType: string, payload: string): any { return; }; + androidApplicationRecord(packageName: string): any { return; }; +} diff --git a/src/@ionic-native-mocks/plugins/onesignal/index.ts b/src/@ionic-native-mocks/plugins/onesignal/index.ts new file mode 100644 index 0000000..ab9838e --- /dev/null +++ b/src/@ionic-native-mocks/plugins/onesignal/index.ts @@ -0,0 +1,547 @@ +import { OneSignal } from '@ionic-native/onesignal'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export interface OSNotification { + /** + * Was app in focus. + */ + isAppInFocus: boolean; + /** + * Was notification shown to the user. Will be false for silent notifications. + */ + shown: boolean; + /** + * **ANDROID** - Android Notification assigned to the notification. Can be used to cancel or replace the notification. + */ + androidNotificationId?: number; + /** + * Payload received from OneSignal. + */ + payload: OSNotificationPayload; + /** + * How the notification was displayed to the user. Can be set to `Notification`, `InAppAlert`, or `None` if it was not displayed. + */ + displayType: OSDisplayType; + /** + * **ANDROID** - Notification is a summary notification for a group this will contain all notification payloads it was created from. + */ + groupedNotifications?: OSNotificationPayload[]; + app_id?: string; + contents: any; + headings?: any; + isIos?: boolean; + isAndroid?: boolean; + isWP?: boolean; + isWP_WNS?: boolean; + isAdm?: boolean; + isChrome?: boolean; + isChromeWeb?: boolean; + isSafari?: boolean; + isAnyWeb?: boolean; + included_segments?: string[]; + excluded_segments?: string[]; + include_player_ids?: string[]; + include_ios_tokens?: string[]; + include_android_reg_ids?: string[]; + include_wp_uris?: string[]; + include_wp_wns_uris?: string[]; + include_amazon_reg_ids?: string[]; + include_chrome_reg_ids?: string[]; + include_chrome_web_reg_ids?: string[]; + app_ids?: string[]; + tags?: any[]; + ios_badgeType?: string; + ios_badgeCount?: number; + ios_sound?: string; + android_sound?: string; + adm_sound?: string; + wp_sound?: string; + wp_wns_sound?: string; + data?: any; + buttons?: any; + small_icon?: string; + large_icon?: string; + big_picture?: string; + adm_small_icon?: string; + adm_large_icon?: string; + adm_big_picture?: string; + chrome_icon?: string; + chrome_big_picture?: string; + chrome_web_icon?: string; + firefox_icon?: string; + url?: string; + send_after?: string; + delayed_option?: string; + delivery_time_of_day?: string; + android_led_color?: string; + android_accent_color?: string; + android_visibility?: number; + content_available?: boolean; + amazon_background_data?: boolean; + template_id?: string; + android_group?: string; + android_group_message?: any; + adm_group?: string; + adm_group_message?: any; + ttl?: number; + priority?: number; + ios_category?: string; +} +/** + * **ANDROID** - Privacy setting for how the notification should be shown on the lockscreen of Android 5+ devices. + */ +export declare enum OSLockScreenVisibility { + /** + * Fully visible (default) + */ + Public = 1, + /** + * Contents are hidden + */ + Private = 0, + /** + * Not shown + */ + Secret = -1, +} +/** + * How the notification was displayed to the user. Part of OSNotification. See inFocusDisplaying for more information on how this is used. + */ +export declare enum OSDisplayType { + /** + * notification is silent, or inFocusDisplaying is disabled. + */ + None = 0, + /** + * (**DEFAULT**) - native alert dialog display. + */ + InAppAlert = 1, + /** + * native notification display. + */ + Notification = 2, +} +/** + * Contents and settings of the notification the user received. + */ +export interface OSNotificationPayload { + /** + * OneSignal notification UUID. + */ + notificationID: string; + /** + * Title of the notification. + */ + title: string; + /** + * Body of the notification. + */ + body: string; + /** + * Custom additional data that was sent with the notification. Set on the dashboard under Options > Additional Data + * or with the 'data' field on the REST API. + */ + additionalData?: any; + /** + * **ANDROID** - Small icon resource name set on the notification. + */ + smallIcon?: string; + /** + * **ANDROID** - Large icon set on the notification. + */ + largeIcon?: string; + /** + * **ANDROID** - Big picture image set on the notification. + */ + bigPicture?: string; + /** + * **ANDROID** - Accent color shown around small notification icon on Android 5+ devices. ARGB format. + */ + smallIconAccentColor?: string; + /** + * URL to open when opening the notification. + */ + launchUrl?: string; + /** + * Sound resource to play when the notification is shown. + */ + sound: string; + /** + * **ANDROID** - Devices that have a notification LED will blink in this color. ARGB format. + */ + ledColor?: string; + lockScreenVisibility?: OSLockScreenVisibility; + /** + * **ANDROID** - Notifications with this same key will be grouped together as a single summary notification. + */ + groupKey?: string; + /** + * **ANDROID** - Summary text displayed in the summary notification. + */ + groupMessage?: string; + /** + * List of action buttons on the notification. + */ + actionButtons: OSActionButton[]; + /** + * **ANDROID** - The Google project number the notification was sent under. + */ + fromProjectNumber?: string; + /** + * **ANDROID** - If a background image was set this object will be available. + */ + backgroundImageLayout?: OSBackgroundImageLayout; + priority?: number; + /** + * List of action buttons on the notification. + */ + rawPayload: string; +} +/** + * List of action buttons on the notification. + */ +export interface OSActionButton { + /** + * Id assigned to the button. + */ + id: string; + /** + * Text show on the button to the user. + */ + text: string; + /** + * **ANDROID** - Icon shown on the button. + */ + icon: string; +} +/** + * OSPermissionState + */ +export interface OSPermissionState { + /** + * User was prompted. + */ + hasPrompted: boolean; + /** + * Permissions Status + */ + status: any; +} +/** + * OSSubscriptionState + */ +export interface OSSubscriptionState { + subscribed: boolean; + userSubscriptionSetting: any; + userId: any; + pushToken: any; +} +/** + * Subscription and permissions status + */ +export interface OSPermissionSubscriptionState { + /** + * Id assigned to the button. + */ + permissionStatus: OSPermissionState; + /** + * Text show on the button to the user. + */ + subscriptionStatus: OSSubscriptionState; +} +/** + * **ANDROID** - If a background image was set, this object will be available. + */ +export interface OSBackgroundImageLayout { + /** + * Image URL or name used as the background image. + */ + image: string; + /** + * Text color of the title on the notification. ARGB Format. + */ + titleTextColor: string; + /** + * Text color of the body on the notification. ARGB Format. + */ + bodyTextColor: string; +} +/** + * The information returned from a notification the user received. + */ +export interface OSNotificationOpenedResult { + action: { + /** + * Was the notification opened normally (`Opened`) or was a button pressed on the notification (`ActionTaken`). + */ + type: OSActionType; + /** + * If `type` == `ActionTaken` then this will contain the id of the button pressed. + */ + actionID?: string; + }; + notification: OSNotification; +} +export declare enum OSActionType { + Opened = 0, + ActionTake = 1, +} + +export class OneSignalMock extends OneSignal { + /** + * constants to use in inFocusDisplaying() + */ + OSInFocusDisplayOption: { + None: number; + InAppAlert: number; + Notification: number; + }; + /** + * Start the initialization process. Once you are done configuring OneSignal, call the `endInit` function. + * + * @param {string} appId Your OneSignal app id + * @param {string} googleProjectNumber **ANDROID** - your Google project number; only required for Android GCM/FCM pushes. + * @returns {any} + */ + startInit(appId: string, googleProjectNumber?: string): any { + return; + }; + /** + * Callback to run when a notification is received, whether it was displayed or not. + * + * @return {Observable} + */ + handleNotificationReceived(): Observable { + let response: OSNotification; + return Observable.create((observer: Observer) => { + observer.next(response); + observer.complete(); + }); + }; + /** + * Callback to run when a notification is tapped on from the notification shade (**ANDROID**) or notification + * center (**iOS**), or when closing an Alert notification shown in the app (if InAppAlert is enabled in + * inFocusDisplaying). + * + * @return {Observable} + */ + handleNotificationOpened(): Observable { + let response: OSNotificationOpenedResult; + return Observable.create((observer: Observer) => { + observer.next(response); + observer.complete(); + }); + }; + /** + * **iOS** - Settings for iOS apps + * + * @param settings + * kOSSettingsKeyAutoPrompt: boolean = true + * Auto prompt user for notification permissions. + * + * kOSSettingsKeyInAppLaunchURL: boolean = false + * Launch notifications with a launch URL as an in app webview. + * @returns {any} + */ + iOSSettings(settings: { + kOSSettingsKeyAutoPrompt: boolean; + kOSSettingsKeyInAppLaunchURL: boolean; + }): any { + return; + }; + /** + * Must be called after `startInit` to complete initialization of OneSignal. + * + * @returns {any} + */ + endInit(): any { + return; + }; + /** + * Prompt the user for notification permissions. Callback fires as soon as the user accepts or declines notifications. + * @returns {Promise} + */ + promptForPushNotificationsWithUserResponse(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Retrieve a list of tags that have been set on the user from the OneSignal server. + * + * **Quirk**: You must wait for `getTags` to resolve before calling it again, as the plugin will only process the last method call and discard any previous ones. + * + * @returns {Promise} Returns a Promise that resolves when tags are recieved. + */ + getTags(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Lets you retrieve the OneSignal user id and device token. + * Your handler is called after the device is successfully registered with OneSignal. + * + * @returns {Promise} Returns a Promise that resolves if the device was successfully registered. + * + * userId {string} OneSignal userId is a UUID formatted string. (unique per device per app) + * + * pushToken {string} A push token is a Google/Apple assigned identifier(unique per device per app). + */ + getIds(): Promise<{ + userId: string; + pushToken: string; + }> { + let response: {userId: string, pushToken: string}; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Tag a user based on an app event of your choosing so later you can create segments on [onesignal.com](https://onesignal.com/) to target these users. + * Recommend using sendTags over sendTag if you need to set more than one tag on a user at a time. + * + * @param {string} Key of your choosing to create or update. + * @param {string} Value to set on the key. NOTE: Passing in a blank String deletes the key, you can also call deleteTag. + */ + sendTag(key: string, value: string): void { }; + /** + * Tag a user based on an app event of your choosing so later you can create segments on [onesignal.com](https://onesignal.com/) to target these users. + * Recommend using sendTags over sendTag if you need to set more than one tag on a user at a time. + * + * @param {string} Pass a json object with key/value pairs like: {key: "value", key2: "value2"} + */ + sendTags(json: any): void { }; + /** + * Deletes a tag that was previously set on a user with `sendTag` or `sendTags`. Use `deleteTags` if you need to delete more than one. + * + * @param {string} Key to remove. + */ + deleteTag(key: string): void { }; + /** + * Deletes tags that were previously set on a user with `sendTag` or `sendTags`. + * + * @param {Array} Keys to remove. + */ + deleteTags(keys: string[]): void { }; + /** + * Call this when you would like to prompt an iOS user to accept push notifications with the default system prompt. + * Only works if you set `kOSSettingsAutoPrompt` to `false` in `iOSSettings` + */ + registerForPushNotifications(): void { }; + /** + * Warning: + * Only applies to Android and Amazon. You can call this from your UI from a button press for example to give your user's options for your notifications. + * + * By default OneSignal always vibrates the device when a notification is displayed unless the device is in a total silent mode. + * Passing false means that the device will only vibrate lightly when the device is in it's vibrate only mode. + * + * @param {boolean} false to disable vibrate, true to re-enable it. + */ + enableVibrate(enable: boolean): void { }; + /** + * Warning: + * Only applies to Android and Amazon. You can call this from your UI from a button press for example to give your user's options for your notifications. + * + * By default OneSignal plays the system's default notification sound when the device's notification system volume is turned on. + * Passing false means that the device will only vibrate unless the device is set to a total silent mode. + * + * @param {boolean} false to disable sound, true to re-enable it. + */ + enableSound(enable: boolean): void { }; + /** + * + * Setting to control how OneSignal notifications will be shown when one is received while your app is in focus. By default this is set to inAppAlert, which can be helpful during development. + * + * @param {DisplayType} displayOption + * @returns {any} + */ + inFocusDisplaying(displayOption: OSDisplayType): any { + return; + }; + /** + * You can call this method with false to opt users out of receiving all notifications through OneSignal. + * You can pass true later to opt users back into notifications. + * + * @param {boolean} enable + */ + setSubscription(enable: boolean): void { }; + /** + * Get the current notification and permission state. Returns a OSPermissionSubscriptionState type described below. + * + * @returns {Promise} + */ + getPermissionSubscriptionState(): Promise { + let response: OSPermissionSubscriptionState; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @param {notificationObj} Parameters see POST [documentation](https://documentation.onesignal.com/v2.0/docs/notifications-create-notification) + * @returns {Promise} Returns a Promise that resolves if the notification was send successfully. + */ + postNotification(notificationObj: OSNotification): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Cancels a single OneSignal notification based on its Android notification integer id. Use instead of NotificationManager.cancel(id); otherwise the notification will be restored when your app is restarted. + * @param notificationId {string} + */ + cancelNotification(notificationId: string): void { }; + /** + * Prompts the user for location permission to allow geotagging based on the "Location radius" filter on the OneSignal dashboard. + */ + promptLocation(): void { }; + /** + * + * @param email {string} + */ + syncHashedEmail(email: string): void { }; + /** + * Enable logging to help debug if you run into an issue setting up OneSignal. + * The logging levels are as follows: 0 = None, 1= Fatal, 2 = Errors, 3 = Warnings, 4 = Info, 5 = Debug, 6 = Verbose + + * The higher the value the more information is shown. + * + * @param {loglevel} contains two properties: logLevel (for console logging) and visualLevel (for dialog messages) + */ + setLogLevel(logLevel: { + logLevel: number; + visualLevel: number; + }): void { }; + /** + * The passed in function will be fired when a notification permission setting changes. + * This includes the following events: + * - Notification permission prompt shown + * - The user accepting or declining the permission prompt + * - Enabling/disabling notifications for your app in the device Settings after returning to your app. + * @return {Observable} + */ + addPermissionObserver(): Observable { + return Observable.create((observer: Observer) => { + observer.next(''); + observer.complete(); + }); + }; + /** + * The passed in function will be fired when a notification subscription property changes. + * This includes the following events: + * - Getting a push token from Apple / Google. + * - Getting a player / user id from OneSignal + * - OneSignal.setSubscription is called + * - User disables or enables notifications + * @return {Observable} + */ + addSubscriptionObserver(): Observable { + return Observable.create((observer: Observer) => { + observer.next(''); + observer.complete(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/paypal/index.ts b/src/@ionic-native-mocks/plugins/paypal/index.ts new file mode 100644 index 0000000..08f97ba --- /dev/null +++ b/src/@ionic-native-mocks/plugins/paypal/index.ts @@ -0,0 +1,362 @@ +import { PayPal } from '@ionic-native/paypal'; + +export class PayPalMock extends PayPal { + /** + * Retrieve the version of the PayPal iOS SDK library. Useful when contacting support. + * @returns {Promise} + */ + version(): Promise { + let response: string = ''; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * You must preconnect to PayPal to prepare the device for processing payments. + * This improves the user experience, by making the presentation of the + * UI faster. The preconnect is valid for a limited time, so + * the recommended time to preconnect is on page load. + * + * @param {PayPalEnvironment} clientIdsForEnvironments: set of client ids for environments + * @returns {Promise} + */ + init(clientIdsForEnvironments: PayPalEnvironment): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * You must preconnect to PayPal to prepare the device for processing payments. + * This improves the user experience, by making the presentation of the UI faster. + * The preconnect is valid for a limited time, so the recommended time to preconnect is on page load. + * + * @param {String} environment: available options are "PayPalEnvironmentNoNetwork", "PayPalEnvironmentProduction" and "PayPalEnvironmentSandbox" + * @param {PayPalConfiguration} configuration: PayPalConfiguration object, for Future Payments merchantName, merchantPrivacyPolicyURL and merchantUserAgreementURL must be set be set + * @returns {Promise} + */ + prepareToRender(environment: string, configuration: PayPalConfiguration): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Start PayPal UI to collect payment from the user. + * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/ios-integration-guide/ + * for more documentation of the params. + * + * @param {PayPalPayment} payment PayPalPayment object + * @returns {Promise} + */ + renderSinglePaymentUI(payment: PayPalPayment): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Once a user has consented to future payments, when the user subsequently initiates a PayPal payment + * from their device to be completed by your server, PayPal uses a Correlation ID to verify that the + * payment is originating from a valid, user-consented device+application. + * This helps reduce fraud and decrease declines. + * This method MUST be called prior to initiating a pre-consented payment (a "future payment") from a mobile device. + * Pass the result to your server, to include in the payment request sent to PayPal. + * Do not otherwise cache or store this value. + * @returns {Promise} + */ + clientMetadataID(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Please Read Docs on Future Payments at https://github.com/paypal/PayPal-iOS-SDK#future-payments + * @returns {Promise} + */ + renderFuturePaymentUI(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Please Read Docs on Profile Sharing at https://github.com/paypal/PayPal-iOS-SDK#profile-sharing + * + * @param {Array} scopes scopes Set of requested scope-values. Accepted scopes are: openid, profile, address, email, phone, futurepayments and paypalattributes + * See https://developer.paypal.com/docs/integration/direct/identity/attributes/ for more details + * @returns {Promise} + */ + renderProfileSharingUI(scopes: string[]): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} +export interface PayPalEnvironment { + PayPalEnvironmentProduction: string; + PayPalEnvironmentSandbox: string; +} +/** + * @hidden + */ +export declare class PayPalPayment { + constructor(amount: string, currency: string, shortDescription: string, intent: string, details?: PayPalPaymentDetails); + /** + * The amount of the payment. + */ + amount: string; + /** + * The ISO 4217 currency for the payment. + */ + currency: string; + /** + * A short description of the payment. + */ + shortDescription: string; + /** + * "Sale" for an immediate payment. + */ + intent: string; + /** + * Optional Build Notation code ("BN code"), obtained from partnerprogram@paypal.com, + * for your tracking purposes. + */ + bnCode: string; + /** + * Optional invoice number, for your tracking purposes. (up to 256 characters) + */ + invoiceNumber: string; + /** + * Optional text, for your tracking purposes. (up to 256 characters) + */ + custom: string; + /** + * Optional text which will appear on the customer's credit card statement. (up to 22 characters) + */ + softDescriptor: string; + /** + * Optional array of PayPalItem objects. + */ + items: Array; + /** + * Optional customer shipping address, if your app wishes to provide this to the SDK. + */ + shippingAddress: string; + /** + * Optional PayPalPaymentDetails object + */ + details: PayPalPaymentDetails; +} +/** + * @hidden + */ +export declare class PayPalItem { + /** + * The PayPalItem class defines an optional itemization for a payment. + * @see https://developer.paypal.com/docs/api/#item-object for more details. + * @param {String} name: Name of the item. 127 characters max + * @param {Number} quantity: Number of units. 10 characters max. + * @param {String} price: Unit price for this item 10 characters max. + * May be negative for "coupon" etc + * @param {String} currency: ISO standard currency code. + * @param {String} sku: The stock keeping unit for this item. 50 characters max (optional) + */ + constructor(name: string, quantity: number, price: string, currency: string, sku?: string); + /** + * Name of the item. 127 characters max + */ + name: string; + /** + * Number of units. 10 characters max. + */ + quantity: number; + /** + * Unit price for this item 10 characters max. + */ + price: string; + /** + * ISO standard currency code. + */ + currency: string; + /** + * The stock keeping unit for this item. 50 characters max (optional) + */ + sku?: string; +} +/** + * @hidden + */ +export declare class PayPalPaymentDetails { + /** + * The PayPalPaymentDetails class defines optional amount details. + * @param {String} subtotal: Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places. + * @param {String} shipping: Amount charged for shipping. 10 characters max with support for 2 decimal places. + * @param {String} tax: Amount charged for tax. 10 characters max with support for 2 decimal places. + */ + constructor(subtotal: string, shipping: string, tax: string); + /** + * Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places. + */ + subtotal: string; + /** + * Amount charged for shipping. 10 characters max with support for 2 decimal places. + */ + shipping: string; + /** + * Amount charged for tax. 10 characters max with support for 2 decimal places. + */ + tax: string; +} +/** + * @hidden + */ +export interface PayPalConfigurationOptions { + /** + * Will be overridden by email used in most recent PayPal login. + */ + defaultUserEmail?: string; + /** + * Will be overridden by phone country code used in most recent PayPal login + */ + defaultUserPhoneCountryCode?: string; + /** + * Will be overridden by phone number used in most recent PayPal login. + */ + defaultUserPhoneNumber?: string; + /** + * Your company name, as it should be displayed to the user when requesting consent via a PayPalFuturePaymentViewController. + */ + merchantName?: string; + /** + * URL of your company's privacy policy, which will be offered to the user when requesting consent via a PayPalFuturePaymentViewController. + */ + merchantPrivacyPolicyURL?: string; + /** + * URL of your company's user agreement, which will be offered to the user when requesting consent via a PayPalFuturePaymentViewController. + */ + merchantUserAgreementURL?: string; + /** + * If set to NO, the SDK will only support paying with PayPal, not with credit cards. + * This applies only to single payments (via PayPalPaymentViewController). + * Future payments (via PayPalFuturePaymentViewController) always use PayPal. + * Defaults to true + */ + acceptCreditCards?: boolean; + /** + * For single payments, options for the shipping address. + * - 0 - PayPalShippingAddressOptionNone: no shipping address applies. + * - 1 - PayPalShippingAddressOptionProvided: shipping address will be provided by your app, + * in the shippingAddress property of PayPalPayment. + * - 2 - PayPalShippingAddressOptionPayPal: user will choose from shipping addresses on file + * for their PayPal account. + * - 3 - PayPalShippingAddressOptionBoth: user will choose from the shipping address provided by your app, + * in the shippingAddress property of PayPalPayment, plus the shipping addresses on file for the user's PayPal account. + * Defaults to 0 (PayPalShippingAddressOptionNone). + */ + payPalShippingAddressOption?: number; + /** + * If set to YES, then if the user pays via their PayPal account, + * the SDK will remember the user's PayPal username or phone number; + * if the user pays via their credit card, then the SDK will remember + * the PayPal Vault token representing the user's credit card. + * + * If set to NO, then any previously-remembered username, phone number, or + * credit card token will be erased, and subsequent payment information will + * not be remembered. + * + * Defaults to YES. + */ + rememberUser?: boolean; + /** + * If not set, or if set to nil, defaults to the device's current language setting. + * + * Can be specified as a language code ("en", "fr", "zh-Hans", etc.) or as a locale ("en_AU", "fr_FR", "zh-Hant_HK", etc.). + * If the library does not contain localized strings for a specified locale, then will fall back to the language. E.g., "es_CO" -> "es". + * If the library does not contain localized strings for a specified language, then will fall back to American English. + * + * If you specify only a language code, and that code matches the device's currently preferred language, + * then the library will attempt to use the device's current region as well. + * E.g., specifying "en" on a device set to "English" and "United Kingdom" will result in "en_GB". + */ + languageOrLocale?: string; + /** + * Normally, the SDK blurs the screen when the app is backgrounded, + * to obscure credit card or PayPal account details in the iOS-saved screenshot. + * If your app already does its own blurring upon backgrounding, you might choose to disable this. + * Defaults to NO. + */ + disableBlurWhenBackgrounding?: boolean; + /** + * If you will present the SDK's view controller within a popover, then set this property to YES. + * Defaults to NO. (iOS only) + */ + presentingInPopover?: boolean; + /** + * Sandbox credentials can be difficult to type on a mobile device. Setting this flag to YES will + * cause the sandboxUserPassword and sandboxUserPin to always be pre-populated into login fields. + */ + forceDefaultsInSandbox?: boolean; + /** + * Password to use for sandbox if 'forceDefaultsInSandbox' is set. + */ + sandboxUserPassword?: string; + /** + * PIN to use for sandbox if 'forceDefaultsInSandbox' is set. + */ + sandboxUserPin?: string; + /** + * @hidden + */ + [key: string]: any; +} +/** + * @hidden + */ +export declare class PayPalConfiguration implements PayPalConfigurationOptions { + /** + * You use a PayPalConfiguration object to configure many aspects of how the SDK behaves. + * see defaults for options available + */ + constructor(options?: PayPalConfigurationOptions); +} +/** + * @hidden + */ +export declare class PayPalShippingAddress { + /** + * See the documentation of the individual properties for more detail. + * @param {String} recipientName: Name of the recipient at this address. 50 characters max. + * @param {String} line1: Line 1 of the address (e.g., Number, street, etc). 100 characters max. + * @param {String} line2: Line 2 of the address (e.g., Suite, apt #, etc). 100 characters max. Optional. + * @param {String} city: City name. 50 characters max. + * @param {String} state: 2-letter code for US states, and the equivalent for other countries. 100 characters max. Required in certain countries. + * @param {String} postalCode: ZIP code or equivalent is usually required for countries that have them. 20 characters max. Required in certain countries. + * @param {String} countryCode: 2-letter country code. 2 characters max. + */ + constructor(recipientName: string, line1: string, line2: string, city: string, state: string, postalCode: string, countryCode: string); + /** + * Name of the recipient at this address. 50 characters max. + */ + recipientName: string; + /** + * Line 1 of the address (e.g., Number, street, etc). 100 characters max. + */ + line1: string; + /** + * Line 2 of the address (e.g., Suite, apt #, etc). 100 characters max. Optional. + */ + line2: string; + /** + * City name. 50 characters max. + */ + city: string; + /** + * 2-letter code for US states, and the equivalent for other countries. 100 characters max. Required in certain countries. + */ + state: string; + /** + * ZIP code or equivalent is usually required for countries that have them. 20 characters max. Required in certain countries. + */ + postalCode: string; + /** + * 2-letter country code. 2 characters max. + */ + countryCode: string; +} diff --git a/src/@ionic-native-mocks/plugins/pedometer/index.ts b/src/@ionic-native-mocks/plugins/pedometer/index.ts new file mode 100644 index 0000000..712562f --- /dev/null +++ b/src/@ionic-native-mocks/plugins/pedometer/index.ts @@ -0,0 +1,90 @@ +import { Pedometer } from '@ionic-native/pedometer'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export interface IPedometerData { + startDate?: number; + endDate?: number; + numberOfSteps: number; + distance: number; + floorsAscended: number; + floorsDescended: number; +} + +export class PedometerMock extends Pedometer { + /** + * Checks if step counting is available. Only works on iOS. + * @return {Promise} Returns a promise that resolves when feature is supported (true) or not supported (false) + */ + isStepCountingAvailable(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Distance estimation indicates the ability to use step information to supply the approximate distance travelled by the user. + * This capability is not supported on all devices, even with iOS 8. + * Only works on iOS. + * @return {Promise} Returns a promise that resolves when feature is supported (true) or not supported (false) + */ + isDistanceAvailable(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Floor counting indicates the ability to count the number of floors the user walks up or down using stairs. + * This capability is not supported on all devices, even with iOS 8. + * Only works on iOS. + * @return {Promise} Returns a promise that resolves when feature is supported (true) or not supported (false) + */ + isFloorCountingAvailable(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Starts the delivery of recent pedestrian-related data to your Cordova app. + * + * When the app is suspended, the delivery of updates stops temporarily. + * Upon returning to foreground or background execution, the pedometer object begins updates again. + * @return {Observable} Returns a Observable that recieves repeatly data from pedometer in background. + */ + startPedometerUpdates(): Observable { + let response: IPedometerData; + return Observable.create((observer: Observer) => { + observer.next(response); + observer.complete(); + }); + }; + /** + * Stops the delivery of recent pedestrian data updates to your Cordova app. + * @return {Promise} Returns a promise that resolves when pedometer watching was stopped + */ + stopPedometerUpdates(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Retrieves the data between the specified start and end dates. + * The startDate and endDate options are required and can be constructed in any valid JavaScript way + * (e.g. new Date(2015, 4, 1, 15, 20, 00) is also valid, as is milliseconds). + * Only works on iOS. + * @param {any} options start date and en date where you want to get pedometer data + * @return {Promise} Returns a promise that resolves when pedometer data found + */ + queryData(options: { + startDate: Date; + endDate: Date; + }): Promise { + let response: IPedometerData ; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/photo-library/index.ts b/src/@ionic-native-mocks/plugins/photo-library/index.ts new file mode 100644 index 0000000..60b506d --- /dev/null +++ b/src/@ionic-native-mocks/plugins/photo-library/index.ts @@ -0,0 +1,163 @@ +import { IonicNativePlugin } from '@ionic-native/core'; +import { Observable } from 'rxjs/Observable'; +/** + * @name Photo Library + * @description + * The PhotoLibrary plugin allows access to photos from device by url. So you can use plain img tag to display photos and their thumbnails, and different 3rd party libraries as well. + * Saving photos and videos to the library is also supported. + * cdvphotolibrary urls should be trusted by Angular. See plugin homepage to learn how. + * + * @usage + * ```typescript + * import { PhotoLibrary } from '@ionic-native/photo-library'; + * + * constructor(private photoLibrary: PhotoLibrary) { } + * + * this.photoLibrary.requestAuthorization().then(() => { + * this.photoLibrary.getLibrary().subscribe({ + * next: library => { + * library.forEach(function(libraryItem) { + * console.log(libraryItem.id); // ID of the photo + * console.log(libraryItem.photoURL); // Cross-platform access to photo + * console.log(libraryItem.thumbnailURL);// Cross-platform access to thumbnail + * console.log(libraryItem.fileName); + * console.log(libraryItem.width); + * console.log(libraryItem.height); + * console.log(libraryItem.creationDate); + * console.log(libraryItem.latitude); + * console.log(libraryItem.longitude); + * console.log(libraryItem.albumIds); // array of ids of appropriate AlbumItem, only of includeAlbumsData was used + * }); + * }, + * error: err => {}, + * complete: () => { console.log('could not get photos'); } + * }); + * }) + * .catch(err => console.log('permissions weren\'t granted')); + * + * ``` + */ +export declare class PhotoLibrary extends IonicNativePlugin { + /** + * Retrieves library items. Library item contains photo metadata like width and height, as well as photoURL and thumbnailURL. + * @param options {GetLibraryOptions} Optional, like thumbnail size and chunks settings. + * @return {Observable} Returns library items. If appropriate option was set, will be returned by chunks. + */ + getLibrary(options?: GetLibraryOptions): Observable; + /** + * Asks user permission to access photo library. + * @param options {RequestAuthorizationOptions} Optional, like whether only read access needed or read/write. + * @return { Promise} Returns a promise that resolves when permissions are granted, and fails when not. + */ + requestAuthorization(options?: RequestAuthorizationOptions): Promise; + /** + * Returns list of photo albums on device. + * @return {Promise} Resolves to list of albums. + */ + getAlbums(): Promise; + /** + * Provides means to request URL of thumbnail, with specified size or quality. + * @param photo {string | LibraryItem} Id of photo, or LibraryItem. + * @param options {GetThumbnailOptions} Options, like thumbnail size or quality. + * @return {Promise} Resolves to URL of cdvphotolibrary schema. + */ + getThumbnailURL(photo: string | LibraryItem, options?: GetThumbnailOptions): Promise; + /** + * Provides means to request photo URL by id. + * @param photo {string | LibraryItem} Id or LibraryItem. + * @param options {GetPhotoOptions} Optional options. + * @return {Promise} Resolves to URL of cdvphotolibrary schema. + */ + getPhotoURL(photo: string | LibraryItem, options?: any): Promise; + /** + * Returns thumbnail as Blob. + * @param photo {string | LibraryItem} Id or LibraryItem. + * @param options {GetThumbnailOptions} Options, like thumbnail size or quality. + * @return {Promise} Resolves requested thumbnail as blob. + */ + getThumbnail(photo: string | LibraryItem, options?: GetThumbnailOptions): Promise; + /** + * Returns photo as Blob. + * @param photo {string | LibraryItem} Id or LibraryItem. + * @param options {GetPhotoOptions} Optional options. + * @return {Promise} Resolves requested photo as blob. + */ + getPhoto(photo: string | LibraryItem, options?: any): Promise; + /** + * Saves image to specified album. Album will be created if not exists. + * LibraryItem that represents saved image is returned. + * @param url {string} URL of a file, or DataURL. + * @param album {AlbumItem | string} Name of an album or AlbumItem object. + * @param options {GetThumbnailOptions} Options, like thumbnail size for resulting LibraryItem. + * @return {Promise} Resolves to LibraryItem that represents saved image. + */ + saveImage(url: string, album: AlbumItem | string, options?: GetThumbnailOptions): Promise; + /** + * Saves video to specified album. Album will be created if not exists. + * @param url {string} URL of a file, or DataURL. + * @param album {AlbumItem | string} Name of an album or AlbumItem object. + * @return {Promise} Resolves when save operation completes. + */ + saveVideo(url: string, album: AlbumItem | string): Promise; +} +/** + * @hidden + */ +export interface LibraryItem { + /** + * Local id of the photo + */ + id: string; + /** + * URL of cdvphotolibrary schema. + */ + photoURL: string; + /** + * URL of cdvphotolibrary schema. + */ + thumbnailURL: string; + fileName: string; + width: number; + height: number; + creationDate: Date; + latitude?: number; + longitude?: number; + albumIds?: string[]; +} +/** + * @hidden + */ +export interface AlbumItem { + /** + * Local id of the album + */ + id: string; + title: string; +} +/** + * @hidden + */ +export interface GetLibraryOptions { + thumbnailWidth?: number; + thumbnailHeight?: number; + quality?: number; + itemsInChunk?: number; + chunkTimeSec?: number; + useOriginalFileNames?: boolean; + includeAlbumData?: boolean; +} +/** + * @hidden + */ +export interface RequestAuthorizationOptions { + read?: boolean; + write?: boolean; +} +/** + * @hidden + */ +export interface GetThumbnailOptions { + thumbnailWidth?: number; + thumbnailHeight?: number; + quality?: number; +} diff --git a/src/@ionic-native-mocks/plugins/photo-viewer/index.ts b/src/@ionic-native-mocks/plugins/photo-viewer/index.ts new file mode 100644 index 0000000..7788916 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/photo-viewer/index.ts @@ -0,0 +1,13 @@ +import { PhotoViewer } from '@ionic-native/photo-viewer'; + +export class PhotoViewerMock extends PhotoViewer { + /** + * Shows an image in full screen + * @param url {string} URL or path to image + * @param title {string} + * @param options {any} + */ + show(url: string, title?: string, options?: { + share?: boolean; + }): void {}; +} diff --git a/src/@ionic-native-mocks/plugins/pin-dialog/index.ts b/src/@ionic-native-mocks/plugins/pin-dialog/index.ts new file mode 100644 index 0000000..d7168dd --- /dev/null +++ b/src/@ionic-native-mocks/plugins/pin-dialog/index.ts @@ -0,0 +1,20 @@ +import { PinDialog } from '@ionic-native/pin-dialog'; + +export class PinDialogMock extends PinDialog { + /** + * Show pin dialog + * @param {string} message Message to show the user + * @param {string} title Title of the dialog + * @param {string[]} buttons Buttons to show + * @returns {Promise<{ buttonIndex: number, input1: string }>} + */ + prompt(message: string, title: string, buttons: string[]): Promise<{ + buttonIndex: number; + input1: string; + }> { + let response: {buttonIndex: number, input1: string } = {buttonIndex: 0, input1: ''}; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/pinterest/index.ts b/src/@ionic-native-mocks/plugins/pinterest/index.ts new file mode 100644 index 0000000..8723609 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/pinterest/index.ts @@ -0,0 +1,323 @@ +import { Pinterest } from '@ionic-native/pinterest'; + +export interface PinterestUser { + /** + * The unique string of numbers and letters that identifies the user on Pinterest. + */ + id?: string; + /** + * The user’s Pinterest username. + */ + username?: string; + /** + * The user’s first name. + */ + first_name?: string; + /** + * The user’s last name. + */ + last_name?: string; + /** + * The text in the user’s “About you” section in their profile. + */ + bio?: string; + /** + * The date the user created their account in ISO 8601 format + */ + created_at?: string; + /** + * The user’s stats, including how many Pins, follows, boards and likes they have. + */ + counts?: any; + /** + * The user’s profile image. The response returns the image’s URL, width and height. + */ + image?: any; +} +export interface PinterestBoard { + /** + * The unique string of numbers and letters that identifies the board on Pinterest. + */ + id?: string; + /** + * The name of the board. + */ + name?: string; + /** + * The link to the board. + */ + url?: string; + /** + * The user-entered description of the board. + */ + description?: string; + /** + * The first and last name, ID and profile URL of the user who created the board. + */ + creator?: PinterestUser; + /** + * The date the user created the board. + */ + created_at?: string; + /** + * The board’s stats, including how many Pins, followers, user's following and collaborators it has. + */ + counts?: any; + /** + * The user’s profile image. The response returns the image’s URL, width and height. + */ + image?: any; +} +export interface PinterestPin { + /** + * The unique string of numbers and letters that identifies the Pin on Pinterest. + */ + id?: string; + /** + * The URL of the webpage where the Pin was created. + */ + link?: string; + /** + * The URL of the Pin on Pinterest. + */ + url?: string; + /** + * The first and last name, ID and profile URL of the user who created the board. + */ + creator?: PinterestUser; + /** + * The board that the Pin is on. + */ + board?: PinterestBoard; + /** + * The date the Pin was created. + */ + created_at?: string; + /** + * The user-entered description of the Pin. + */ + note?: string; + /** + * The dominant color of the Pin’s image in hex code format. + */ + color?: string; + /** + * The Pin’s stats, including the number of repins, comments and likes. + */ + counts?: any; + /** + * The media type of the Pin (image or video). + */ + media?: any; + /** + * The source data for videos, including the title, URL, provider, author name, author URL and provider name. + */ + attribution?: any; + /** + * The Pin’s image. The default response returns the image’s URL, width and height. + */ + image?: any; + /** + * Extra information about the Pin for Rich Pins. Includes the Pin type (e.g., article, recipe) and related information (e.g., ingredients, author). + */ + metadata?: any; +} + +export class PinterestMock extends Pinterest { + /** + * Convenience constant for authentication scopes + */ + SCOPES: { + READ_PUBLIC: string; + WRITE_PUBLIC: string; + READ_RELATIONSHIPS: string; + WRITE_RELATIONSHIPS: string; + }; + /** + * Logs the user in using their Pinterest account. + * @param scopes {Array} Array of scopes that you need access to. You can use Pinterest.SCOPES constant for convenience. + * @returns {Promise} The response object will contain the user's profile data, as well as the access token (if you need to use it elsewhere, example: send it to your server and perform actions on behalf of the user). + */ + login(scopes: string[]): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Gets the authenticated user's profile + * @param fields {string} Fields to retrieve, separated by commas. Defaults to all available fields. + * @returns {Promise} Returns a promise that resolves with the user's object + */ + getMe(fields?: string): Promise { + let response: PinterestUser; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @param fields {string} Optional fields separated by comma + * @param limit {number} Optional limit, defaults to 100, maximum is 100. + * @returns {Promise>} + */ + getMyPins(fields?: string, limit?: number): Promise> { + let response: Array = []; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * + * @param fields {string} Optional fields separated by comma + * @param limit {number} Optional limit, defaults to 100, maximum is 100. + * @returns {Promise>} + */ + getMyBoards(fields?: string, limit?: number): Promise> { + let response: Array = []; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Get the authenticated user's likes. + * @param fields {string} Optional fields separated by comma + * @param limit {number} Optional limit, defaults to 100, maximum is 100. + * @returns {Promise>} + */ + getMyLikes(fields?: string, limit?: number): Promise> { + let response: Array = []; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Get the authenticated user's followers. + * @param fields {string} Optional fields separated by comma + * @param limit {number} Optional limit, defaults to 100, maximum is 100. + * @returns {Promise>} + */ + getMyFollowers(fields?: string, limit?: number): Promise> { + let response: Array = []; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Get the authenticated user's followed boards. + * @param fields {string} Optional fields separated by comma + * @param limit {number} Optional limit, defaults to 100, maximum is 100. + * @returns {Promise>} + */ + getMyFollowedBoards(fields?: string, limit?: number): Promise> { + let response: Array = []; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Get the authenticated user's followed interests. + * @param fields {string} Optional fields separated by comma + * @param limit {number} Optional limit, defaults to 100, maximum is 100. + * @returns {Promise} + */ + getMyFollowedInterests(fields?: string, limit?: number): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Get a user's profile. + * @param username + * @param fields + * @returns {Promise} + */ + getUser(username: string, fields?: string): Promise { + let response: PinterestUser; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Get a board's data. + * @param boardId + * @param fields + * @returns {Promise} + */ + getBoard(boardId: string, fields?: string): Promise { + let response: PinterestBoard; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Get Pins of a specific board. + * @param boardId {string} The ID of the board + * @param fields {string} Optional fields separated by comma + * @param limit {number} Optional limit, defaults to 100, maximum is 100. + * @returns {Promise>} + */ + getBoardPins(boardId: string, fields?: string, limit?: number): Promise> { + let response: Array = []; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Delete a board. + * @param boardId {string} The ID of the board + * @returns {Promise} + */ + deleteBoard(boardId: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Create a new board for the authenticated user. + * @param name {string} Name of the board + * @param desc {string} Optional description of the board + * @returns {Promise} + */ + createBoard(name: string, desc?: string): Promise { + let response: PinterestBoard; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Get a Pin by ID. + * @param pinId {string} The ID of the Pin + * @param fields {string} Optional fields separated by comma + * @returns {Promise} + */ + getPin(pinId: string, fields?: string): Promise { + let response: PinterestPin; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Deletes a pin + * @param pinId {string} The ID of the pin + * @returns {Promise} + */ + deletePin(pinId: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Creates a Pin + * @param note {string} Note/Description of the pin + * @param boardId {string} Board ID to put the Pin under + * @param imageUrl {string} URL of the image to share + * @param link {string} Optional link to share + * @returns {Promise} + */ + createPin(note: string, boardId: string, imageUrl: string, link?: string): Promise { + let response: PinterestPin; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/power-management/index.ts b/src/@ionic-native-mocks/plugins/power-management/index.ts new file mode 100644 index 0000000..5f7c8db --- /dev/null +++ b/src/@ionic-native-mocks/plugins/power-management/index.ts @@ -0,0 +1,42 @@ +import { PowerManagement } from '@ionic-native/power-management'; + +export class PowerManagementMock extends PowerManagement { + /** + * Acquire a wakelock by calling this. + * @returns {Promise} + */ + acquire(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * This acquires a partial wakelock, allowing the screen to be dimmed. + * @returns {Promise} + */ + dim(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Release the wakelock. It's important to do this when you're finished with the wakelock, to avoid unnecessary battery drain. + * @returns {Promise} + */ + release(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * By default, the plugin will automatically release a wakelock when your app is paused (e.g. when the screen is turned off, or the user switches to another app). + * It will reacquire the wakelock upon app resume. If you would prefer to disable this behaviour, you can use this function. + * @param set {boolean} + * @returns {Promise} + */ + setReleaseOnPause(set: boolean): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/printer/index.ts b/src/@ionic-native-mocks/plugins/printer/index.ts new file mode 100644 index 0000000..6e7aa97 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/printer/index.ts @@ -0,0 +1,75 @@ +import { Printer } from '@ionic-native/printer'; +export interface PrintOptions { + /** + * The name of the print job and the document + */ + name?: string; + /** + * The network URL of the printer. + * Only supported on iOS. + */ + printerId?: string; + /** + * Specifies the duplex mode to use for the print job. + * Either double-sided (duplex:true) or single-sided (duplex:false). + * Double-sided by default. + * Only supported on iOS + */ + duplex?: boolean; + /** + * The orientation of the printed content, portrait or landscape + * Portrait by default. + */ + landscape?: boolean; + /** + * If your application only prints black text, setting this property to true can result in better performance in many cases. + * False by default. + */ + grayscale?: boolean; + /** + * The Size and position of the print view + */ + bounds?: number[] | any; +} + +export class PrinterMock extends Printer { + /** + * Checks whether the device is capable of printing (uses `check()` internally) + * @returns {Promise} + */ + isAvailable(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Checks if the printer service is available (iOS) or if printer services are installed and enabled (Android). + * @return {Promise} returns a promise that resolve with an object indicating whether printing is available, and providing the number of printers available + */ + check(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Displays a system interface allowing the user to select an available printer. To speak with a printer directly you need to know the network address by picking them before via `printer.pick`. + * @returns {Promise} + */ + pick(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Sends content to the printer. + * @param content {string | HTMLElement} The content to print. Can be a URL or an HTML string. If a HTML DOM Object is provided, its innerHtml property value will be used. + * @param options {PrintOptions} optional. The options to pass to the printer + * @returns {Promise} + */ + print(content: string | HTMLElement, options?: PrintOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/rollbar/index.ts b/src/@ionic-native-mocks/plugins/rollbar/index.ts new file mode 100644 index 0000000..e1f1a74 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/rollbar/index.ts @@ -0,0 +1,13 @@ +import { Rollbar } from '@ionic-native/rollbar'; + +export class RollbarMock extends Rollbar { + /** + * This function initializes the monitoring of your application + * @return {Promise} Returns a promise that resolves when the plugin successfully initializes + */ + init(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/safari-view-controller/index.ts b/src/@ionic-native-mocks/plugins/safari-view-controller/index.ts new file mode 100644 index 0000000..b69ee5e --- /dev/null +++ b/src/@ionic-native-mocks/plugins/safari-view-controller/index.ts @@ -0,0 +1,76 @@ +import { SafariViewController } from '@ionic-native/safari-view-controller'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export interface SafariViewControllerOptions { + animated?: boolean; + barColor?: string; + controlTintColor?: string; + enterReaderModeIfAvailable?: boolean; + hidden?: boolean; + showDefaultShareMenuItem?: boolean; + tintColor?: string; + toolbarColor?: string; + transition?: string; + url?: string; +} + +export class SafariViewControllerMock extends SafariViewController { + /** + * Checks if SafariViewController is available + * @returns {Promise} + */ + isAvailable(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Shows Safari View Controller + * @param options {SafariViewControllerOptions} optional + * @returns {Observable} + */ + show(options?: SafariViewControllerOptions): Observable { + return Observable.create((observer: Observer) => { + observer.next(''); + observer.complete(); + }); + }; + /** + * Hides Safari View Controller + */ + hide(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Tries to connect to the Chrome's custom tabs service. you must call this method before calling any of the other methods listed below. + * @returns {Promise} + */ + connectToService(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Call this method whenever there's a chance the user will open an external url. + * @returns {Promise} + */ + warmUp(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * For even better performance optimization, call this methods if there's more than a 50% chance the user will open a certain URL. + * @param url{string} + * @returns {Promise} + */ + mayLaunchUrl(url: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/screenshot/index.ts b/src/@ionic-native-mocks/plugins/screenshot/index.ts new file mode 100644 index 0000000..d17339c --- /dev/null +++ b/src/@ionic-native-mocks/plugins/screenshot/index.ts @@ -0,0 +1,31 @@ +import { Screenshot } from '@ionic-native/screenshot'; + +export class ScreenshotMock extends Screenshot { + /** + * Takes screenshot and saves the image + * + * @param format {string} Format can take the value of either 'jpg' or 'png' + * On ios, only 'jpg' format is supported + * @param quality {number} Determines the quality of the screenshot. + * Default quality is set to 100. + * @param filename {string} Name of the file as stored on the storage + * @returns {Promise} + */ + save(format?: string, quality?: number, filename?: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Takes screenshot and returns the image as an URI + * + * @param quality {number} Determines the quality of the screenshot. + * Default quality is set to 100. + * @returns {Promise} + */ + URI(quality?: number): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/serial/index.ts b/src/@ionic-native-mocks/plugins/serial/index.ts new file mode 100644 index 0000000..3e4bfa8 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/serial/index.ts @@ -0,0 +1,90 @@ +import { Serial } from '@ionic-native/serial'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export interface SerialPermissionOptions { + vid: string; + pid: string; + driver: string; +} +export interface SerialOpenOptions { + baudRate: number; +} + +export class SerialMock extends Serial { + /** + * Request permission to connect to a serial device + * + * @param options {SerialPermissionOptions} Options used to request serial permissions for an unknown device + * @return {Promise} Returns a promise that resolves when permissions are granted + */ + requestPermission(options?: SerialPermissionOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Open connection to a serial device + * + * @param options {SerialOpenOptions} Options used to open serial connection + * @return {Promise} Returns a promise that resolves when the serial connection is opened + */ + open(options: SerialOpenOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Write to a serial connection + * + * @param data {any} data to write to the serial connection + * @return {Promise} Returns a promise that resolves when the write is complete + */ + write(data: any): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Write hex to a serial connection + * + * @param data {any} data to write to the serial connection + * @return {Promise} Returns a promise that resolves when the write is complete + */ + writeHex(data: any): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Read from a serial connection + * + * @return {Promise} Returns a promise that resolves with data read from the serial connection + */ + read(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Watch the incoming data from the serial connection. Clear the watch by unsubscribing from the observable + * + * @returns {Observable} Observable returns an observable that you can subscribe to + */ + registerReadCallback(): Observable { + return Observable.create((observer: Observer) => { + observer.next(''); + observer.complete(); + }); + }; + /** + * Close the serial connection + * + * @return {Promise} Returns a promise that resolves when the serial connection is closed + */ + close(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/shake/index.ts b/src/@ionic-native-mocks/plugins/shake/index.ts new file mode 100644 index 0000000..be2ab17 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/shake/index.ts @@ -0,0 +1,17 @@ +import { Shake } from '@ionic-native/shake'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export class ShakeMock extends Shake { + /** + * Watch for shake gesture + * @param sensitivity {number} Optional sensitivity parameter. Defaults to 40 + * @returns {Observable} + */ + startWatch(sensitivity?: number): Observable { + return Observable.create((observer: Observer) => { + observer.next(''); + observer.complete(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/sim/index.ts b/src/@ionic-native-mocks/plugins/sim/index.ts new file mode 100644 index 0000000..2bca259 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/sim/index.ts @@ -0,0 +1,49 @@ +import { IonicNativePlugin } from '@ionic-native/core'; +/** + * @name Sim + * @description + * Gets info from the Sim card like the carrier name, mcc, mnc and country code and other system dependent info. + * + * Requires Cordova plugin: `cordova-plugin-sim`. For more info, please see the [Cordova Sim docs](https://github.com/pbakondy/cordova-plugin-sim). + * + * @usage + * ```typescript + * import { Sim } from '@ionic-native/sim'; + * + * + * constructor(private sim: Sim) { } + * + * ... + * + * this.sim.getSimInfo().then( + * (info) => console.log('Sim info: ', info), + * (err) => console.log('Unable to get sim info: ', err) + * ); + * + * this.sim.hasReadPermission().then( + * (info) => console.log('Has permission: ', info) + * ); + * + * this.sim.requestReadPermission().then( + * () => console.log('Permission granted'), + * () => console.log('Permission denied') + * ); + * ``` + */ +export declare class Sim extends IonicNativePlugin { + /** + * Returns info from the SIM card. + * @returns {Promise} + */ + getSimInfo(): Promise; + /** + * Check permission + * @returns {Promise} + */ + hasReadPermission(): Promise; + /** + * Request permission + * @returns {Promise} + */ + requestReadPermission(): Promise; +} diff --git a/src/@ionic-native-mocks/plugins/sms/index.ts b/src/@ionic-native-mocks/plugins/sms/index.ts new file mode 100644 index 0000000..7ad94e6 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/sms/index.ts @@ -0,0 +1,42 @@ +import { SMS } from '@ionic-native/sms'; +/** + * Options for sending an SMS + */ +export interface SmsOptions { + /** + * Set to true to replace \n by a new line. Default: false + */ + replaceLineBreaks?: boolean; + android?: SmsOptionsAndroid; +} +export interface SmsOptionsAndroid { + /** + * Set to "INTENT" to send SMS with the native android SMS messaging. Leaving it empty will send the SMS without opening any app. + */ + intent?: string; +} + +export class SMSMock extends SMS { + /** + * Sends sms to a number + * @param phoneNumber {string|Array} Phone number + * @param message {string} Message + * @param options {SmsOptions} Options + * @returns {Promise} Resolves promise when the SMS has been sent + */ + send(phoneNumber: string | string[], message: string, options?: SmsOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * This function lets you know if the app has permission to send SMS + * @return {Promise} returns a promise that resolves with a boolean that indicates if we have permission + */ + hasPermission(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/speech-recognition/index.ts b/src/@ionic-native-mocks/plugins/speech-recognition/index.ts new file mode 100644 index 0000000..c2c8486 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/speech-recognition/index.ts @@ -0,0 +1,98 @@ +import { SpeechRecognition } from '@ionic-native/speech-recognition'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export declare type SpeechRecognitionListeningOptions = SpeechRecognitionListeningOptionsIOS | SpeechRecognitionListeningOptionsAndroid; +export interface SpeechRecognitionListeningOptionsIOS { + /** + * used language for recognition (default `"en-US"`) + */ + language?: string; + /** + * umber of return matches (default `5`) + */ + matches?: number; + /** + * Allow partial results to be returned (default `false`) + */ + showPartial?: boolean; +} +export interface SpeechRecognitionListeningOptionsAndroid { + /** + * used language for recognition (default `"en-US"`) + */ + language?: string; + /** + * number of return matches (maximum number of matches) + */ + matches?: number; + /** + * displayed prompt of listener popup window + */ + prompt?: string; + /** + * display listener popup window with prompt (default `true`) + */ + showPopup?: boolean; +} + +export class SpeechRecognitionMock extends SpeechRecognition { + /** + * Check feature available + * @return {Promise} + */ + isRecognitionAvailable(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Start the recognition process + * @return {Promise< Array >} list of recognized terms + */ + startListening(options?: SpeechRecognitionListeningOptions): Observable> { + let response: Array = []; + return Observable.create((observer: Observer) => { + observer.next(response); + observer.complete(); + }); + }; + /** + * Stop the recognition process + */ + stopListening(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Get the list of supported languages + * @return {Promise< Array >} list of languages + */ + getSupportedLanguages(): Promise> { + let response: Array = []; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Check permission + * @return {Promise} has permission + */ + hasPermission(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Request permissions + * @return {Promise} + */ + requestPermission(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/spinner-dialog/index.ts b/src/@ionic-native-mocks/plugins/spinner-dialog/index.ts new file mode 100644 index 0000000..f3f2e41 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/spinner-dialog/index.ts @@ -0,0 +1,22 @@ +import { SpinnerDialog } from '@ionic-native/spinner-dialog'; +export interface SpinnerDialogIOSOptions { + overlayOpacity?: number; + textColorRed?: number; + textColorGreen?: number; + textColorBlue?: number; +} + +export class SpinnerDialogMock extends SpinnerDialog { + /** + * Shows the spinner dialog + * @param title {string} Spinner title (shows on Android only) + * @param message {string} Spinner message + * @param cancelCallback {boolean|function} Set to true to set spinner not cancelable. Or provide a function to call when the user cancels the spinner. + * @param iOSOptions {object} Options for iOS only + */ + show(title?: string, message?: string, cancelCallback?: any, iOSOptions?: SpinnerDialogIOSOptions): void {}; + /** + * Hides the spinner dialog if visible + */ + hide(): void {}; +} diff --git a/src/@ionic-native-mocks/plugins/sqlite-porter/index.ts b/src/@ionic-native-mocks/plugins/sqlite-porter/index.ts new file mode 100644 index 0000000..05d35e4 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/sqlite-porter/index.ts @@ -0,0 +1,56 @@ +import { SQLitePorter } from '@ionic-native/sqlite-porter'; + +export class SQLitePorterMock extends SQLitePorter { + /** + * Executes a set of SQL statements against the defined database. Can be used to import data defined in the SQL statements into the database, and may additionally include commands to create the table structure. + * @param db {Object} Database object + * @param sql {string} SQL statements to execute against the database + * @return {Promise} + */ + importSqlToDb(db: any, sql: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Exports a SQLite DB as a set of SQL statements. + * @param db {Object} Database object + * @return {Promise} + */ + exportDbToSql(db: any): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Converts table structure and/or row data contained within a JSON structure into SQL statements that can be executed against a SQLite database. Can be used to import data into the database and/or create the table structure. + * @param db {Object} Database object + * @param json {Object|string} JSON structure containing row data and/or table structure as either a JSON object or string + * @return {Promise} + */ + importJsonToDb(db: any, json: any): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Exports a SQLite DB as a JSON structure + * @param db {Object} Database object + * @return {Promise} + */ + exportDbToJson(db: any): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Wipes all data from a database by dropping all existing tables + * @param db {Object} Database object + * @return {Promise} + */ + wipeDb(db: any): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/stepcounter/index.ts b/src/@ionic-native-mocks/plugins/stepcounter/index.ts new file mode 100644 index 0000000..7d05e93 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/stepcounter/index.ts @@ -0,0 +1,60 @@ +import { Stepcounter } from '@ionic-native/stepcounter'; + +export class StepcounterMock extends Stepcounter { + /** + * Start the step counter + * + * @param startingOffset {number} will be added to the total steps counted in this session + * @returns {Promise} Returns a Promise that resolves on success or rejects on failure + */ + start(startingOffset: number): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Stop the step counter + * @returns {Promise} Returns a Promise that resolves on success with the amount of steps since the start command has been called, or rejects on failure + */ + stop(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Get the amount of steps for today (or -1 if it no data given) + * @returns {Promise} Returns a Promise that resolves on success with the amount of steps today, or rejects on failure + */ + getTodayStepCount(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Get the amount of steps since the start command has been called + * @returns {Promise} Returns a Promise that resolves on success with the amount of steps since the start command has been called, or rejects on failure + */ + getStepCount(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Returns true/false if Android device is running >API level 19 && has the step counter API available + * @returns {Promise} Returns a Promise that resolves on success, or rejects on failure + */ + deviceCanCountSteps(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Get the step history (JavaScript object) + * @returns {Promise} Returns a Promise that resolves on success, or rejects on failure + */ + getHistory(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/streaming-media/index.ts b/src/@ionic-native-mocks/plugins/streaming-media/index.ts new file mode 100644 index 0000000..35c2b32 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/streaming-media/index.ts @@ -0,0 +1,42 @@ +import { StreamingMedia } from '@ionic-native/streaming-media'; + +export interface StreamingVideoOptions { + successCallback?: Function; + errorCallback?: Function; + orientation?: string; +} +export interface StreamingAudioOptions { + bgColor?: string; + bgImage?: string; + bgImageScale?: string; + initFullscreen?: boolean; + successCallback?: Function; + errorCallback?: Function; +} + +export class StreamingMediaMock extends StreamingMedia { + /** + * Streams a video + * @param videoUrl {string} The URL of the video + * @param options {StreamingVideoOptions} Options + */ + playVideo(videoUrl: string, options?: StreamingVideoOptions): void {}; + /** + * Streams an audio + * @param audioUrl {string} The URL of the audio stream + * @param options {StreamingAudioOptions} Options + */ + playAudio(audioUrl: string, options?: StreamingAudioOptions): void {}; + /** + * Stops streaming audio + */ + stopAudio(): void {}; + /** + * Pauses streaming audio + */ + pauseAudio(): void {}; + /** + * Resumes streaming audio + */ + resumeAudio(): void {}; +} diff --git a/src/@ionic-native-mocks/plugins/stripe/index.ts b/src/@ionic-native-mocks/plugins/stripe/index.ts new file mode 100644 index 0000000..847242d --- /dev/null +++ b/src/@ionic-native-mocks/plugins/stripe/index.ts @@ -0,0 +1,155 @@ +import { Stripe } from '@ionic-native/stripe'; + +export interface StripeCardTokenParams { + /** + * Card number + */ + number: string; + /** + * Expiry month + */ + expMonth: number; + /** + * Expiry year + */ + expYear: number; + /** + * CVC / CVV + */ + cvc?: string; + /** + * Cardholder name + */ + name?: string; + /** + * Address line 1 + */ + address_line1?: string; + /** + * Address line 2 + */ + address_line2?: string; + /** + * City + */ + address_city?: string; + /** + * State / Province + */ + address_state?: string; + /** + * Country + */ + address_country?: string; + /** + * Postal code / ZIP Code + */ + postal_code?: string; + /** + * 3-letter ISO code for currency + */ + currency?: string; +} +export interface StripeBankAccountParams { + /** + * Routing number. + */ + routing_number: string; + /** + * Account number. + */ + account_number: string; + /** + * Currency code. Example: `USD`. + */ + currency: string; + /** + * Country code. Example: `US`. + */ + country: string; + /** + * Account holder name. + */ + account_holder_name?: string; + /** + * Account holder type. This can be `individual` or `company`. + */ + account_holder_type?: string; +} + +export class StripeMock extends Stripe { + /** + * Set publishable key + * @param publishableKey {string} Publishable key + * @return {Promise} + */ + setPublishableKey(publishableKey: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Create Credit Card Token + * @param params {StripeCardTokenParams} Credit card information + * @return {Promise} returns a promise that resolves with the token, or rejects with an error + */ + createCardToken(params: StripeCardTokenParams): Promise { + let response: string = ''; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Create a bank account token + * @param params {StripeBankAccountParams} Bank account information + * @return {Promise} returns a promise that resolves with the token, or rejects with an error + */ + createBankAccountToken(params: StripeBankAccountParams): Promise { + let response: string = ''; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Validates a credit card number + * @param cardNumber {string} Credit card number + * @return {Promise} returns a promise that resolves if the number is valid, and rejects if it's invalid + */ + validateCardNumber(cardNumber: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Validates a CVC number + * @param cvc {string} CVC number + * @return {Promise} returns a promise that resolves if the number is valid, and rejects if it's invalid + */ + validateCVC(cvc: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Validates an expiry date + * @param expMonth {string} expiry month + * @param expYear {string} expiry year + * @return {Promise} returns a promise that resolves if the date is valid, and rejects if it's invalid + */ + validateExpiryDate(expMonth: string, expYear: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Get a card type from card number + * @param cardNumber {string} Card number + * @return {Promise} returns a promise that resolves with the credit card type + */ + getCardType(cardNumber: string): Promise { + let response: string = ''; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/taptic-engine/index.ts b/src/@ionic-native-mocks/plugins/taptic-engine/index.ts new file mode 100644 index 0000000..53f0d20 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/taptic-engine/index.ts @@ -0,0 +1,39 @@ +import { TapticEngine } from '@ionic-native/taptic-engine'; + +export class TapticEngineMock extends TapticEngine { + /** + * Use selection feedback generators to indicate a change in selection. + * @returns {Promise} Returns a promise that resolves on success and rejects on error + */ + selection(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Use this to indicate success/failure/warning to the user. + * @param options {Object} should be of the type { type: 'success' } (or 'warning'/'error') + * @param options.type {string} + * @returns {Promise} Returns a promise that resolves on success and rejects on error + */ + notification(options: { + type: string; + }): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Use this to indicate success/failure/warning to the user. + * @param options {Object} should be of the type { style: 'light' } (or 'medium'/'heavy') + * @param options.type {string} + * @returns {Promise} Returns a promise that resolves on success and rejects on error + */ + impact(options: { + style: string; + }): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/text-to-speech/index.ts b/src/@ionic-native-mocks/plugins/text-to-speech/index.ts new file mode 100644 index 0000000..3d2dadc --- /dev/null +++ b/src/@ionic-native-mocks/plugins/text-to-speech/index.ts @@ -0,0 +1,32 @@ +import { TextToSpeech } from '@ionic-native/text-to-speech'; + +export interface TTSOptions { + /** text to speak */ + text: string; + /** a string like 'en-US', 'zh-CN', etc */ + locale?: string; + /** speed rate, 0 ~ 1 */ + rate?: number; +} + +export class TextToSpeechMock extends TextToSpeech { + /** + * This function speaks + * @param textOrOptions {string | TTSOptions} Text to speak or TTSOptions + * @return {Promise} Returns a promise that resolves when the speaking finishes + */ + speak(textOrOptions: string | TTSOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Stop any current TTS playback + * @return {Promise} + */ + stop(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/themeable-browser/index.ts b/src/@ionic-native-mocks/plugins/themeable-browser/index.ts new file mode 100644 index 0000000..a653e21 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/themeable-browser/index.ts @@ -0,0 +1,137 @@ +import { ThemeableBrowser, ThemeableBrowserObject } from '@ionic-native/themeable-browser'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export interface ThemeableBrowserButton { + wwwImage?: string; + image?: string; + wwwImagePressed?: string; + imagePressed?: string; + wwwImageDensity?: number; + align?: string; + event?: string; +} +export interface ThemeableBrowserOptions { + statusbar?: { + color: string; + }; + toolbar?: { + height?: number; + color?: string; + image?: string; + }; + title?: { + color?: string; + staticText?: string; + showPageTitle?: boolean; + }; + backButton?: ThemeableBrowserButton; + forwardButton?: ThemeableBrowserButton; + closeButton?: ThemeableBrowserButton; + customButtons?: ThemeableBrowserButton[]; + menu?: { + image?: string; + imagePressed?: string; + title?: string; + cancel?: string; + align?: string; + items?: { + event: string; + label: string; + }[]; + }; + backButtonCanClose?: boolean; + disableAnimation?: boolean; + location?: string; + hidden?: string; + clearcache?: string; + clearsessioncache?: string; + zoom?: string; + hardwareback?: string; + mediaPlaybackRequiresUserAction?: string; + shouldPauseOnSuspsend?: string; + closebuttoncaption?: string; + disallowoverscroll?: string; + enableViewportScale?: string; + allowInlineMediaPlayback?: string; + keyboardDisplayRequiresUserAction?: string; + suppressesIncrementalRendering?: string; + presentationstyle?: string; + transitionstyle?: string; + toolbarposition?: string; + fullscreen?: string; +} +/** + * @hidden + */ +export class ThemeableBrowserObjectMock extends ThemeableBrowserObject { + // private _objectInstance; + constructor(url: string, target: string, styleOptions: ThemeableBrowserOptions) { + super(url, target, styleOptions); + }; + /** + * Displays an browser window that was opened hidden. Calling this has no effect + * if the browser was already visible. + */ + show(): void {}; + /** + * Closes the browser window. + */ + close(): void {}; + /** + * Reloads the current page + */ + reload(): void {} ; + /** + * Injects JavaScript code into the browser window. + * @param script Details of the script to run, specifying either a file or code key. + * @returns {Promise} + */ + executeScript(script: { + file?: string; + code?: string; + }): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Injects CSS into the browser window. + * @param css Details of the script to run, specifying either a file or code key. + * @returns {Promise} + */ + insertCss(css: { + file?: string; + code?: string; + }): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * A method that allows you to listen to events happening in the browser. + * Available events are: `ThemeableBrowserError`, `ThemeableBrowserWarning`, `critical`, `loadfail`, `unexpected`, `undefined` + * @param event Event name + * @returns {Observable} Returns back an observable that will listen to the event on subscribe, and will stop listening to the event on unsubscribe. + */ + on(event: string): Observable { + return Observable.create((observer: Observer) => { + observer.next(''); + observer.complete(); + }); + }; +} + +export class ThemeableBrowserMock extends ThemeableBrowser { + /** + * Creates a browser instance + * @param url {string} URL to open + * @param target {string} Target + * @param styleOptions {ThemeableBrowserOptions} Themeable browser options + * @returns {ThemeableBrowserObject} + */ + create(url: string, target: string, styleOptions: ThemeableBrowserOptions): ThemeableBrowserObject { + let response: ThemeableBrowserObject; + return response; + }; +} diff --git a/src/@ionic-native-mocks/plugins/three-dee-touch/index.ts b/src/@ionic-native-mocks/plugins/three-dee-touch/index.ts new file mode 100644 index 0000000..5a81977 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/three-dee-touch/index.ts @@ -0,0 +1,96 @@ +import { ThreeDeeTouch } from '@ionic-native/three-dee-touch'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export interface ThreeDeeTouchQuickAction { + /** + * Type that can be used in the onHomeIconPressed callback + */ + type?: string; + /** + * Title + */ + title: string; + /** + * Subtitle + */ + subtitle?: string; + /** + * Icon type. Case insensitive + */ + iconType?: string; + /** + * Icon template + */ + iconTemplate?: string; +} +export interface ThreeDeeTouchForceTouch { + /** + * Touch force + */ + force: number; + /** + * Timestamp of action + */ + timestamp: number; + /** + * X coordinate of action + */ + x: number; + /** + * Y coordinate of action + */ + y: number; +} + +export class ThreeDeeTouchMock extends ThreeDeeTouch { + /** + * You need an iPhone 6S or some future tech to use the features of this plugin, so you can check at runtime if the user's device is supported. + * @returns {Promise} returns a promise that resolves with a boolean that indicates whether the plugin is available or not + */ + isAvailable(): Promise { + let response: boolean = true; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * You can get a notification when the user force touches the webview. The plugin defines a Force Touch when at least 75% of the maximum force is applied to the screen. Your app will receive the x and y coordinates, so you have to figure out which UI element was touched. + * @returns {Observable} Returns an observable that sends a `ThreeDeeTouchForceTouch` object + */ + watchForceTouches(): Observable { + let response: ThreeDeeTouchForceTouch; + return Observable.create((observer: Observer) => { + observer.next(response); + observer.complete(); + }); + }; + /** + * setup the 3D-touch actions, takes an array of objects with the following + * @param {string} type (optional) A type that can be used `onHomeIconPressed` callback + * @param {string} title Title for your action + * @param {string} subtitle (optional) A short description for your action + * @param {string} iconType (optional) Choose between Prohibit, Contact, Home, MarkLocation, Favorite, Love, Cloud, Invitation, Confirmation, Mail, Message, Date, Time, CapturePhoto, CaptureVideo, Task, TaskCompleted, Alarm, Bookmark, Shuffle, Audio, Update + * @param {string} iconTemplate (optional) Can be used to provide your own icon + */ + configureQuickActions(quickActions: Array): void { }; + /** + * When a home icon is pressed, your app launches and this JS callback is invoked. + * @returns {Observable} returns an observable that notifies you when he user presses on the home screen icon + */ + onHomeIconPressed(): Observable { + return Observable.create((observer: Observer) => { + observer.next(''); + observer.complete(); + }); + }; + /** + * Enable Link Preview. + * UIWebView and WKWebView (the webviews powering Cordova apps) don't allow the fancy new link preview feature of iOS9. + */ + enableLinkPreview(): void { }; + /** + * Disabled the link preview feature, if enabled. + */ + disableLinkPreview(): void { }; +} diff --git a/src/@ionic-native-mocks/plugins/twitter-connect/index.ts b/src/@ionic-native-mocks/plugins/twitter-connect/index.ts new file mode 100644 index 0000000..d1c1540 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/twitter-connect/index.ts @@ -0,0 +1,50 @@ +import { TwitterConnect } from '@ionic-native/twitter-connect'; +export interface TwitterConnectResponse { + /** + * Twitter Username + */ + userName: string; + /** + * Twitter User ID + */ + userId: string; + /** + * Twitter OAuth Secret + */ + secret: string; + /** + * Twitter OAuth Token + */ + token: string; +} + +export class TwitterConnectMock extends TwitterConnect { + /** + * Logs in + * @returns {Promise} returns a promise that resolves if logged in and rejects if failed to login + */ + login(): Promise { + let response: TwitterConnectResponse; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Logs out + * @returns {Promise} returns a promise that resolves if logged out and rejects if failed to logout + */ + logout(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Returns user's profile information + * @returns {Promise} returns a promise that resolves if user profile is successfully retrieved and rejects if request fails + */ + showUser(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/unique-device-id/index.ts b/src/@ionic-native-mocks/plugins/unique-device-id/index.ts new file mode 100644 index 0000000..bf70168 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/unique-device-id/index.ts @@ -0,0 +1,14 @@ +import { UniqueDeviceID } from '@ionic-native/unique-device-id'; + +export class UniqueDeviceIDMock extends UniqueDeviceID { + /** + * Gets a unique, cross-install, app-specific device id. + * @return {Promise} Returns a promise that resolves when something happens + */ + get(): Promise { + let response: string = ''; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/user-agent/index.ts b/src/@ionic-native-mocks/plugins/user-agent/index.ts new file mode 100644 index 0000000..1fdbded --- /dev/null +++ b/src/@ionic-native-mocks/plugins/user-agent/index.ts @@ -0,0 +1,32 @@ +import { UserAgent } from '@ionic-native/user-agent'; + +export class UserAgentMock extends UserAgent { + /** + * Changes the current user-agent to the one sent by argument. + * @param userAgent {string} User-Agent + * @return {Promise} Returns a promise that resolves when the user-agent changes + */ + set(userAgent: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Returns the current user-agent string. + * @return {Promise} Returns a promise that resolves when the user-agent is returned + */ + get(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Sets the user-agent back to default + * @return {Promise} Returns a promise that resolves when the user-agent resets + */ + reset(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/video-capture-plus/index.ts b/src/@ionic-native-mocks/plugins/video-capture-plus/index.ts new file mode 100644 index 0000000..6ebb2f7 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/video-capture-plus/index.ts @@ -0,0 +1,97 @@ +import { VideoCapturePlus } from '@ionic-native/video-capture-plus'; + +export interface MediaFile { + /** + * The name of the file, without path information. + */ + name: string; + /** + * The full path of the file, including the name. + */ + fullPath: string; + /** + * The file's mime type + */ + type: string; + /** + * The date and time when the file was last modified. + */ + lastModifiedDate: Date; + /** + * The size of the file, in bytes. + */ + size: number; + /** + * Retrieves the format information of the media file. + * @param {Function} successCallback + * @param {Function} [errorCallback] + */ + getFormatData(successCallback: (data: MediaFileData) => any, errorCallback?: (err: any) => any): any; +} +export interface MediaFileData { + /** + * The actual format of the audio and video content. + */ + codecs: string; + /** + * The average bitrate of the content. The value is zero for images. + */ + bitrate: number; + /** + * The height of the image or video in pixels. The value is zero for audio clips. + */ + height: number; + /** + * The width of the image or video in pixels. The value is zero for audio clips. + */ + width: number; + /** + * The length of the video or sound clip in seconds. The value is zero for images. + */ + duration: number; +} +export interface VideoCapturePlusOptions { + /** + * The number of videos to record, default 1 (on iOS always 1) + */ + limit?: number; + /** + * Max duration in seconds, default 0, which is 'forever' + */ + duration?: number; + /** + * Set to true to override the default low quality setting + */ + highquality?: boolean; + /** + * Set to true to override the default backfacing camera setting. + * You'll want to sniff the useragent/device and pass the best overlay based on that.. assuming iphone here + */ + frontcamera?: boolean; + /** + * put the png overlay in your assets folder + */ + portraitOverlay?: string; + /** + * not passing an overlay means no image is shown for the landscape orientation + */ + landscapeOverlay?: string; + /** + * iOS only + */ + overlayText?: string; +} + +export class VideoCapturePlusMock extends VideoCapturePlus { + /** + * Starts recordings + * @param [options] {VideoCapturePlusOptions} Configure options + * @return {Promise} + */ + captureVideo(options?: VideoCapturePlusOptions): Promise { + let response: Array = []; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/video-editor/index.ts b/src/@ionic-native-mocks/plugins/video-editor/index.ts new file mode 100644 index 0000000..e89d21a --- /dev/null +++ b/src/@ionic-native-mocks/plugins/video-editor/index.ts @@ -0,0 +1,135 @@ +import { VideoEditor } from '@ionic-native/video-editor'; + +export interface TranscodeOptions { + /** The path to the video on the device. */ + fileUri: string; + /** The file name for the transcoded video */ + outputFileName: string; + /** Instructions on how to encode the video. Android is always mp4 */ + outputFileType?: number; + /** Should the video be processed with quailty or speed in mind. iOS only */ + optimizeForNetworkUse?: number; + /** Save the new video the library. Not supported in windows. Defaults to true */ + saveToLibrary?: boolean; + /** Delete the original video. Android only. Defaults to false */ + deleteInputFile?: boolean; + /** iOS only. Defaults to true */ + maintainAspectRatio?: boolean; + /** Width of the result */ + width?: number; + /** Height of the result */ + height?: number; + /** Bitrate in bits. Defaults to 1 megabit (1000000). */ + videoBitrate?: number; + /** Frames per second of the result. Android only. Defaults to 24. */ + fps?: number; + /** Number of audio channels. iOS only. Defaults to 2. */ + audioChannels?: number; + /** Sample rate for the audio. iOS only. Defaults to 44100*/ + audioSampleRate?: number; + /** Sample rate for the audio. iOS only. Defaults to 128 kilobits (128000). */ + audioBitrate?: number; + /** Not supported in windows, progress on the transcode. info will be a number from 0 to 100 */ + progress?: (info: number) => void; +} +export interface TrimOptions { + /** Path to input video. */ + fileUri: string; + /** Time to start trimming in seconds */ + trimStart: number; + /** Time to end trimming in seconds */ + trimEnd: number; + /** Output file name */ + outputFileName: string; + /** Progress on transcode. info will be a number from 0 to 100 */ + progress?: (info: any) => void; +} +export interface CreateThumbnailOptions { + /** The path to the video on the device */ + fileUri: string; + /** The file name for the JPEG image */ + outputFileName: string; + /** Location in the video to create the thumbnail (in seconds) */ + atTime?: number; + /** Width of the thumbnail. */ + width?: number; + /** Height of the thumbnail. */ + height?: number; + /** Quality of the thumbnail (between 1 and 100). */ + quality?: number; +} +export interface GetVideoInfoOptions { + /** The path to the video on the device. */ + fileUri: string; +} +export interface VideoInfo { + /** Width of the video in pixels. */ + width: number; + /** Height of the video in pixels. */ + height: number; + /** Orientation of the video. Will be either portrait or landscape. */ + orientation: 'portrait' | 'landscape'; + /** Duration of the video in seconds. */ + duration: number; + /** Size of the video in bytes. */ + size: number; + /** Bitrate of the video in bits per second. */ + bitrate: number; +} + +export class VideoEditorMock extends VideoEditor { + OptimizeForNetworkUse: { + NO: number; + YES: number; + }; + OutputFileType: { + M4V: number; + MPEG4: number; + M4A: number; + QUICK_TIME: number; + }; + /** + * Transcode a video + * @param options {TranscodeOptions} Options + * @returns {Promise} Returns a promise that resolves to the path of the transcoded video + */ + transcodeVideo(options: TranscodeOptions): Promise { + let response: string = ''; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Trim a video + * @param options {TrimOptions} Options + * @returns {Promise} Returns a promise that resolves to the path of the trimmed video + */ + trim(options: TrimOptions): Promise { + let response: string = ''; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Create a JPEG thumbnail from a video + * @param options {CreateThumbnailOptions} Options + * @returns {Promise} Returns a promise that resolves to the path to the jpeg image on the device + */ + createThumbnail(options: CreateThumbnailOptions): Promise { + let response: string = ''; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Get info on a video (width, height, orientation, duration, size, & bitrate) + * @param options {GetVideoInfoOptions} Options + * @returns {Promise} Returns a promise that resolves to an object containing info on the video + */ + getVideoInfo(options: GetVideoInfoOptions): Promise { + let response: VideoInfo; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/video-player/index.ts b/src/@ionic-native-mocks/plugins/video-player/index.ts new file mode 100644 index 0000000..0746bef --- /dev/null +++ b/src/@ionic-native-mocks/plugins/video-player/index.ts @@ -0,0 +1,34 @@ +import { VideoPlayer } from '@ionic-native/video-player'; +/** + * Options for the video playback using the `play` function. + */ +export interface VideoOptions { + /** + * Set the initial volume of the video playback, where 0.0 is 0% volume and 1.0 is 100%. + * For example: for a volume of 30% set the value to 0.3. + */ + volume?: number; + /** + * There are to options for the scaling mode. SCALE_TO_FIT which is default and SCALE_TO_FIT_WITH_CROPPING. + * These strings are the only ones which can be passed as option. + */ + scalingMode?: number; +} + +export class VideoPlayerMock extends VideoPlayer { + /** + * Plays the video from the passed url. + * @param fileUrl {string} File url to the video. + * @param options {VideoOptions?} Optional video playback settings. See options above. + * @returns {Promise} Resolves promise when the video was played successfully. + */ + play(fileUrl: string, options?: VideoOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Stops the video playback immediatly. + */ + close(): void {}; +} diff --git a/src/@ionic-native-mocks/plugins/web-intent/index.ts b/src/@ionic-native-mocks/plugins/web-intent/index.ts new file mode 100644 index 0000000..99a452b --- /dev/null +++ b/src/@ionic-native-mocks/plugins/web-intent/index.ts @@ -0,0 +1,164 @@ +import { WebIntent } from '@ionic-native/web-intent'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export class WebIntentMock extends WebIntent { + /** + * Convenience constant for actions + * @type {string} + */ + ACTION_SEND: string; + /** + * Convenience constant for actions + * @type {string} + */ + ACTION_VIEW: string; + /** + * Convenience constant for extras + * @type {string} + */ + EXTRA_TEXT: string; + /** + * Convenience constant for extras + * @type {string} + */ + EXTRA_SUBJECT: string; + /** + * Convenience constant for extras + * @type {string} + */ + EXTRA_STREAM: string; + /** + * Convenience constant for extras + * @type {string} + */ + EXTRA_EMAIL: string; + /** + * Convenience constant for actions + * @type {string} + */ + ACTION_CALL: string; + /** + * Convenience constant for actions + * @type {string} + */ + ACTION_SENDTO: string; + /** + * Convenience constant for actions + * @type {string} + */ + ACTION_GET_CONTENT: string; + /** + * Convenience constant for actions + * @type {string} + */ + ACTION_PICK: string; + /** + * Launches an Android intent + * @param options {Object} { action: any, url: string, type?: string } + * @returns {Promise} + */ + startActivity(options: { + action: any; + url: string; + type?: string; + }): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Starts a new activity and return the result to the application + * @param options {Object} { action: any, url: string, type?: string } + * @returns {Promise} + */ + startActivityForResult(options: { + action: any; + url: string; + type?: string; + }): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Checks if this app was invoked with specified extra + * @param extra {string} + * @returns {Promise} + */ + hasExtra(extra: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Gets the extra that this app was invoked with + * @param extra {string} + * @returns {Promise} + */ + getExtra(extra: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Gets the Uri the app was invoked with + * @returns {Promise} + */ + getUri(): Promise { + let response: string = ''; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * @returns {Observable} + */ + onNewIntent(): Observable { + let response: string = ''; + return Observable.create((observer: Observer) => { + observer.next(response); + observer.complete(); + }); + }; + /** + * Sends a custom intent passing optional extras + * @param options {Object} { action: string, extras?: { option: boolean } } + * @returns {Promise} + */ + sendBroadcast(options: { + action: string; + extras?: { + option: boolean; + }; + }): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Registers a broadcast receiver for the specified filters + * @param filters {any} + */ + registerBroadcastReceiver(filters: any): void { }; + /** + * Unregisters a broadcast receiver + */ + unregisterBroadcastReceiver(): void { }; + /** + * Returns the content of the intent used whenever the application activity is launched + */ + onIntent(): void { }; + /** + * + */ + onActivityResult(): void { }; + /** + * @returns {Promise} + */ + getIntent(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/wheel-selector/index.ts b/src/@ionic-native-mocks/plugins/wheel-selector/index.ts new file mode 100644 index 0000000..b544258 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/wheel-selector/index.ts @@ -0,0 +1,75 @@ +import { WheelSelector } from '@ionic-native/wheel-selector'; + +export interface WheelSelectorItem { + description?: string; +} +export interface DefaultItem { + index: number; + value: string; +} +export interface WheelSelectorOptions { + /** + * The title of the selector's input box + */ + title: string; + /** + * The items to display (array of items). + */ + items: Array>; + /** + * Which items to display by default. + */ + defaultItems?: Array; + /** + * The 'ok' button text + * Default: Done + */ + positiveButtonText?: string; + /** + * The 'cancel' button text + * Default: Cancel + */ + negativeButtonText?: string; + /** + * Android only - theme color, 'light' or 'dark'. + * Default: light + */ + theme?: string; + /** + * Whether to have the wheels 'wrap' (Android only) + * Default: false + */ + wrapWheelText?: boolean; + /** + * The json key to display, by default it is description, this allows for setting any + * key/value to be displayed + * Default: description + */ + displayKey?: string; +} +export interface WheelSelectorData { + data: any; +} + +export class WheelSelectorMock extends WheelSelector { + /** + * Shows the wheel selector + * @param {WheelSelectorOptions} options Options for the wheel selector + * @returns {Promise} Returns a promise that resolves with the selected items, or an error. + */ + show(options: WheelSelectorOptions): Promise { + let response: WheelSelectorData; + return new Promise((resolve, reject) => { + resolve( response ); + }); + }; + /** + * Hide the selector + * @returns {Promise} + */ + hideSelector(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/youtube-video-player/index.ts b/src/@ionic-native-mocks/plugins/youtube-video-player/index.ts new file mode 100644 index 0000000..1190451 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/youtube-video-player/index.ts @@ -0,0 +1,9 @@ +import { YoutubeVideoPlayer } from '@ionic-native/youtube-video-player'; + +export class YoutubeVideoPlayerMock extends YoutubeVideoPlayer { + /** + * Plays a YouTube video + * @param videoId {string} Video ID + */ + openVideo(videoId: string): void {}; +} diff --git a/src/@ionic-native-mocks/plugins/zbar/index.ts b/src/@ionic-native-mocks/plugins/zbar/index.ts new file mode 100644 index 0000000..6f1aaa0 --- /dev/null +++ b/src/@ionic-native-mocks/plugins/zbar/index.ts @@ -0,0 +1,44 @@ +import { ZBar } from '@ionic-native/zbar'; + +export interface ZBarOptions { + /** + * A string representing the title text (Android only). + * Default: "Scan QR Code" + */ + text_title?: string; + /** + * A string representing the instruction text (Android only). + * Default: "Please point your camera at the QR code." + */ + text_instructions?: string; + /** + * A string defining the active camera when opening the scanner. + * Possible values: "front", "back" + * Default: "back" + */ + camera?: string; + /** + * A string defining the state of the flash. + * Possible values: "on", "off", "auto" + * Default: "auto" + */ + flash?: string; + /** + * A boolean to show or hide a line in the center of the scanner. + * Default: true + */ + drawSight?: boolean; +} + +export class ZBarMock extends ZBar { + /** + * Open the scanner + * @param options { ZBarOptions } Scan options + * @returns {Promise} Returns a Promise that resolves with the scanned string, or rejects with an error. + */ + scan(options: ZBarOptions): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/zeroconf/index.ts b/src/@ionic-native-mocks/plugins/zeroconf/index.ts new file mode 100644 index 0000000..2f034fb --- /dev/null +++ b/src/@ionic-native-mocks/plugins/zeroconf/index.ts @@ -0,0 +1,100 @@ +import { Zeroconf } from '@ionic-native/zeroconf'; +import { Observable } from 'rxjs/Observable'; +import { Observer } from 'rxjs/Observer'; + +export interface ZeroconfService { + domain: string; + type: string; + name: string; + port: number; + hostname: string; + ipv4Addresses: Array; + ipv6Addresses: Array; + txtRecord: any; +} +export interface ZeroconfResult { + action: 'registered' | 'added' | 'removed'; + service: ZeroconfService; +} + +export class ZeroconfMock extends Zeroconf { + /** + * Returns this device's hostname. + * @return {Promise} + */ + getHostname(): Promise { + let response: string = ''; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Publishes a new service. + * @param type {string} Service type name, e.g. "_http._tcp". + * @param domain {string} Domain scope of the service, typically "local.". + * @param name {string} Unqualified service instance name. + * @param port {number} Local port on which the service runs. + * @param txtRecord {any} Arbitrary key/value pairs describing the service. + * @return {Promise} Returns a Promise that resolves with the registered service. + */ + register(type: string, domain: string, name: string, port: number, txtRecord: any): Promise { + let response: ZeroconfResult; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; + /** + * Unregisters a service. + * @param type {string} Service type name, e.g. "_http._tcp". + * @param domain {string} Domain scope of the service, typically "local.". + * @param name {string} Unqualified service instance name. + * @return {Promise} + */ + unregister(type: string, domain: string, name: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Unregisters all published services. + * @return {Promise} + */ + stop(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Starts watching for services of the specified type. + * @param type {string} Service type name, e.g. "_http._tcp". + * @param domain {string} Domain scope of the service, typically "local.". + * @return {Observable} Returns an Observable that notifies of each service added or removed. + */ + watch(type: string, domain: string): Observable { + let response: ZeroconfResult; + return Observable.create((observer: Observer) => { + observer.next(response); + observer.complete(); + }); + }; + /** + * Stops watching for services of the specified type. + * @param type {string} Service type name, e.g. "_http._tcp". + * @param domain {string} Domain scope of the service, typically "local.". + * @return {Promise} + */ + unwatch(type: string, domain: string): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; + /** + * Closes the service browser and stops watching. + * @return {Promise} + */ + close(): Promise { + return new Promise((resolve, reject) => { + resolve(); + }); + }; +} diff --git a/src/@ionic-native-mocks/plugins/zip/index.ts b/src/@ionic-native-mocks/plugins/zip/index.ts new file mode 100644 index 0000000..d829d8e --- /dev/null +++ b/src/@ionic-native-mocks/plugins/zip/index.ts @@ -0,0 +1,17 @@ +import { Zip } from '@ionic-native/zip'; + +export class ZipMock extends Zip { + /** + * Extracts files from a ZIP archive + * @param sourceZip {string} Source ZIP file + * @param destUrl {string} Destination folder + * @param onProgress {Function} optional callback to be called on progress update + * @returns {Promise} returns a promise that resolves with a number. 0 is success, -1 is error + */ + unzip(sourceZip: string, destUrl: string, onProgress?: Function): Promise { + let response: number; + return new Promise((resolve, reject) => { + resolve(response); + }); + }; +}