Skip to content

Commit

Permalink
Adding Final Mocks
Browse files Browse the repository at this point in the history
native-geocoder
native-keyboard
native-page-transitions
native-ringtones
native-storage
navigation-bar
nfc
onesignal
paypal
pedometer
photo-library
photo-viewer
pin-dialog
pinterest
power-management
printer
rollbar
safari-view-controller
screenshot
serial
shake
sim
sms
speech-recognition
spinner-dialog
sqlite-porter
stepcounter
streaming-media
stripe
taptic-engine
text-to-speech
themeable-browser
three-dee-touch
twitter-connect
unique-device-id
user-agent
video-capture-plus
video-editor
video-player
web-intent
wheel-selector
youtube-video-player
zbar
zeroconf
zip
  • Loading branch information
chrisgriffith committed Jul 26, 2017
1 parent 79bc816 commit c679f3d
Show file tree
Hide file tree
Showing 52 changed files with 4,832 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> (https://aj-sofwtare.com)",
Expand Down
24 changes: 24 additions & 0 deletions src/@ionic-native-mocks/plugins/market/index.ts
Original file line number Diff line number Diff line change
@@ -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<any>}
*/
open(appId: string): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
* Search apps by keyword
* @param keyword {string} Keyword
* @return {Promise<any>}
*/
search(keyword: string): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
}
175 changes: 175 additions & 0 deletions src/@ionic-native-mocks/plugins/media-capture/index.ts
Original file line number Diff line number Diff line change
@@ -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<MediaFile[]>}
*/
captureAudio(options?: CaptureAudioOptions): Promise<MediaFile[] | CaptureError> {
let response: Array<MediaFile> = [];
return new Promise((resolve, reject) => {
resolve(response);
});
};
/**
* Start the camera application and return information about captured image files.
* @param options
* @returns {Promise<MediaFile[]>}
*/
captureImage(options?: CaptureImageOptions): Promise<MediaFile[] | CaptureError> {
let response: Array<MediaFile> = [];
return new Promise((resolve, reject) => {
resolve(response);
});
};
/**
* Start the video recorder application and return information about captured video clip files.
* @param options
* @returns {Promise<MediaFile[]>}
*/
captureVideo(options?: CaptureVideoOptions): Promise<MediaFile[] | CaptureError> {
let response: Array<MediaFile> = [];
return new Promise((resolve, reject) => {
resolve(response);
});
};
/**
* is fired if the capture call is successful
* @returns {Observable<MediaFile[]>}
*/
onPendingCaptureResult(): Observable<MediaFile[]> {
let response: Array<MediaFile> = [];
return Observable.create((observer: Observer<any>) => {
observer.next(response);
observer.complete();
});
};
/**
* is fired if the capture call is unsuccessful
* @returns {Observable<CaptureError>}
*/
onPendingCaptureError(): Observable<CaptureError> {
let response: Array<MediaFile> = [];
return Observable.create((observer: Observer<any>) => {
observer.next(response);
observer.complete();
});
};
}
147 changes: 147 additions & 0 deletions src/@ionic-native-mocks/plugins/mixpanel/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import { Mixpanel, MixpanelPeople } from '@ionic-native/mixpanel';

export class MixpanelMock extends Mixpanel {
/**
*
* @param aliasId {string}
* @param originalId {string}
* @returns {Promise<any>}
*/
alias(aliasId: string, originalId: string): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
*
* @returns {Promise<any>}
*/
distinctId(): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
* @returns {Promise<any>}
*/
flush(): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
*
* @param distinctId {string}
* @returns {Promise<any>}
*/
identify(distinctId: string): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
*
* @param token {string}
* @returns {Promise<any>}
*/
init(token: string): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
*
* @param superProperties {any}
* @returns {Promise<any>}
*/
registerSuperProperties(superProperties: any): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
*
* @returns {Promise<any>}
*/
reset(): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
*
* @param eventName {string}
* @returns {Promise<any>}
*/
timeEvent(eventName: string): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
*
* @param eventName {string}
* @param eventProperties {any} optional
* @returns {Promise<any>}
*/
track(eventName: string, eventProperties?: any): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
}
/**
* @hidden
*/
export class MixpanelPeopleMock extends MixpanelPeople {
/**
*
* @param distinctId {string}
* @return {Promise<any>}
*/
identify(distinctId: string): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
*
* @param peopleProperties {string}
* @return {Promise<any>}
*/
increment(peopleProperties: any): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
*
* @param pushId
* @return {Promise<any>}
*/
setPushId(pushId: string): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
*
* @param peopleProperties
* @return {Promise<any>}
*/
set(peopleProperties: any): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
/**
*
* @param peopleProperties
* @return {Promise<any>}
*/
setOnce(peopleProperties: any): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
};
}
Loading

0 comments on commit c679f3d

Please sign in to comment.