Skip to content

Commit c679f3d

Browse files
committed
Adding Final Mocks
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
1 parent 79bc816 commit c679f3d

52 files changed

Lines changed: 4832 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ionic-native-mocks",
3-
"version": "2.0.1",
3+
"version": "2.0.3",
44
"description": "Mocks for Ionic Native for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
55
"homepage": "https://ionicframework.com/",
66
"author": "Chris Griffith <chris.griffith@gmail.com> (https://aj-sofwtare.com)",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Market } from '@ionic-native/market';
2+
3+
export class MarketMock extends Market {
4+
/**
5+
* Opens an app in Google Play / App Store
6+
* @param appId {string} Package name
7+
* @return {Promise<any>}
8+
*/
9+
open(appId: string): Promise<any> {
10+
return new Promise((resolve, reject) => {
11+
resolve();
12+
});
13+
};
14+
/**
15+
* Search apps by keyword
16+
* @param keyword {string} Keyword
17+
* @return {Promise<any>}
18+
*/
19+
search(keyword: string): Promise<any> {
20+
return new Promise((resolve, reject) => {
21+
resolve();
22+
});
23+
};
24+
}
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
import { MediaCapture } from '@ionic-native/media-capture';
2+
import { Observable } from 'rxjs/Observable';
3+
import { Observer } from 'rxjs/Observer';
4+
5+
export interface MediaFile {
6+
/**
7+
* The name of the file, without path information.
8+
*/
9+
name: string;
10+
/**
11+
* The full path of the file, including the name.
12+
*/
13+
fullPath: string;
14+
/**
15+
* The file's mime type
16+
*/
17+
type: string;
18+
/**
19+
* The date and time when the file was last modified.
20+
*/
21+
lastModifiedDate: Date;
22+
/**
23+
* The size of the file, in bytes.
24+
*/
25+
size: number;
26+
/**
27+
* Retrieves the format information of the media file.
28+
* @param {Function} successCallback
29+
* @param {Function} errorCallback
30+
*/
31+
getFormatData(successCallback: (data: MediaFileData) => any, errorCallback?: (err: any) => any): void;
32+
}
33+
export interface MediaFileData {
34+
/**
35+
* The actual format of the audio and video content.
36+
*/
37+
codecs: string;
38+
/**
39+
* The average bitrate of the content. The value is zero for images.
40+
*/
41+
bitrate: number;
42+
/**
43+
* The height of the image or video in pixels. The value is zero for audio clips.
44+
*/
45+
height: number;
46+
/**
47+
* The width of the image or video in pixels. The value is zero for audio clips.
48+
*/
49+
width: number;
50+
/**
51+
* The length of the video or sound clip in seconds. The value is zero for images.
52+
*/
53+
duration: number;
54+
}
55+
export interface CaptureError {
56+
code: string;
57+
}
58+
export interface CaptureAudioOptions {
59+
/**
60+
* Maximum number of audio clips. Defaults to 1.
61+
* On iOS you can only record one file.
62+
*/
63+
limit?: number;
64+
/**
65+
* Maximum duration of an audio sound clip, in seconds. This does not work on Android devices.
66+
*/
67+
duration?: number;
68+
}
69+
export interface CaptureImageOptions {
70+
/**
71+
* Maximum number of images to capture. This limit is not supported on iOS, only one image will be taken per invocation.
72+
*/
73+
limit?: number;
74+
}
75+
export interface CaptureVideoOptions {
76+
/**
77+
* Maximum number of video clips to record. This value is ignored on iOS, only one video clip can be taken per invocation.
78+
*/
79+
limit?: number;
80+
/**
81+
* Maximum duration per video clip. This will be ignored on BlackBerry.
82+
*/
83+
duration?: number;
84+
/**
85+
* Quality of the video. This parameter can only be used with Android.
86+
*/
87+
quality?: number;
88+
}
89+
export interface ConfigurationData {
90+
/**
91+
* The ASCII-encoded lowercase string representing the media type.
92+
*/
93+
type: string;
94+
/**
95+
* The height of the image or video in pixels. The value is zero for sound clips.
96+
*/
97+
height: number;
98+
/**
99+
* The width of the image or video in pixels. The value is zero for sound clips.
100+
*/
101+
width: number;
102+
}
103+
104+
export class MediaCaptureMock extends MediaCapture {
105+
/**
106+
* The recording image sizes and formats supported by the device.
107+
* @returns {ConfigurationData[]}
108+
*/
109+
supportedImageModes: ConfigurationData[];
110+
/**
111+
* The audio recording formats supported by the device.
112+
* @returns {ConfigurationData[]}
113+
*/
114+
supportedAudioModes: ConfigurationData[];
115+
/**
116+
* The recording video resolutions and formats supported by the device.
117+
* @returns {ConfigurationData[]}
118+
*/
119+
supportedVideoModes: ConfigurationData[];
120+
/**
121+
* Start the audio recorder application and return information about captured audio clip files.
122+
* @param options
123+
* @returns {Promise<MediaFile[]>}
124+
*/
125+
captureAudio(options?: CaptureAudioOptions): Promise<MediaFile[] | CaptureError> {
126+
let response: Array<MediaFile> = [];
127+
return new Promise((resolve, reject) => {
128+
resolve(response);
129+
});
130+
};
131+
/**
132+
* Start the camera application and return information about captured image files.
133+
* @param options
134+
* @returns {Promise<MediaFile[]>}
135+
*/
136+
captureImage(options?: CaptureImageOptions): Promise<MediaFile[] | CaptureError> {
137+
let response: Array<MediaFile> = [];
138+
return new Promise((resolve, reject) => {
139+
resolve(response);
140+
});
141+
};
142+
/**
143+
* Start the video recorder application and return information about captured video clip files.
144+
* @param options
145+
* @returns {Promise<MediaFile[]>}
146+
*/
147+
captureVideo(options?: CaptureVideoOptions): Promise<MediaFile[] | CaptureError> {
148+
let response: Array<MediaFile> = [];
149+
return new Promise((resolve, reject) => {
150+
resolve(response);
151+
});
152+
};
153+
/**
154+
* is fired if the capture call is successful
155+
* @returns {Observable<MediaFile[]>}
156+
*/
157+
onPendingCaptureResult(): Observable<MediaFile[]> {
158+
let response: Array<MediaFile> = [];
159+
return Observable.create((observer: Observer<any>) => {
160+
observer.next(response);
161+
observer.complete();
162+
});
163+
};
164+
/**
165+
* is fired if the capture call is unsuccessful
166+
* @returns {Observable<CaptureError>}
167+
*/
168+
onPendingCaptureError(): Observable<CaptureError> {
169+
let response: Array<MediaFile> = [];
170+
return Observable.create((observer: Observer<any>) => {
171+
observer.next(response);
172+
observer.complete();
173+
});
174+
};
175+
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import { Mixpanel, MixpanelPeople } from '@ionic-native/mixpanel';
2+
3+
export class MixpanelMock extends Mixpanel {
4+
/**
5+
*
6+
* @param aliasId {string}
7+
* @param originalId {string}
8+
* @returns {Promise<any>}
9+
*/
10+
alias(aliasId: string, originalId: string): Promise<any> {
11+
return new Promise((resolve, reject) => {
12+
resolve();
13+
});
14+
};
15+
/**
16+
*
17+
* @returns {Promise<any>}
18+
*/
19+
distinctId(): Promise<any> {
20+
return new Promise((resolve, reject) => {
21+
resolve();
22+
});
23+
};
24+
/**
25+
* @returns {Promise<any>}
26+
*/
27+
flush(): Promise<any> {
28+
return new Promise((resolve, reject) => {
29+
resolve();
30+
});
31+
};
32+
/**
33+
*
34+
* @param distinctId {string}
35+
* @returns {Promise<any>}
36+
*/
37+
identify(distinctId: string): Promise<any> {
38+
return new Promise((resolve, reject) => {
39+
resolve();
40+
});
41+
};
42+
/**
43+
*
44+
* @param token {string}
45+
* @returns {Promise<any>}
46+
*/
47+
init(token: string): Promise<any> {
48+
return new Promise((resolve, reject) => {
49+
resolve();
50+
});
51+
};
52+
/**
53+
*
54+
* @param superProperties {any}
55+
* @returns {Promise<any>}
56+
*/
57+
registerSuperProperties(superProperties: any): Promise<any> {
58+
return new Promise((resolve, reject) => {
59+
resolve();
60+
});
61+
};
62+
/**
63+
*
64+
* @returns {Promise<any>}
65+
*/
66+
reset(): Promise<any> {
67+
return new Promise((resolve, reject) => {
68+
resolve();
69+
});
70+
};
71+
/**
72+
*
73+
* @param eventName {string}
74+
* @returns {Promise<any>}
75+
*/
76+
timeEvent(eventName: string): Promise<any> {
77+
return new Promise((resolve, reject) => {
78+
resolve();
79+
});
80+
};
81+
/**
82+
*
83+
* @param eventName {string}
84+
* @param eventProperties {any} optional
85+
* @returns {Promise<any>}
86+
*/
87+
track(eventName: string, eventProperties?: any): Promise<any> {
88+
return new Promise((resolve, reject) => {
89+
resolve();
90+
});
91+
};
92+
}
93+
/**
94+
* @hidden
95+
*/
96+
export class MixpanelPeopleMock extends MixpanelPeople {
97+
/**
98+
*
99+
* @param distinctId {string}
100+
* @return {Promise<any>}
101+
*/
102+
identify(distinctId: string): Promise<any> {
103+
return new Promise((resolve, reject) => {
104+
resolve();
105+
});
106+
};
107+
/**
108+
*
109+
* @param peopleProperties {string}
110+
* @return {Promise<any>}
111+
*/
112+
increment(peopleProperties: any): Promise<any> {
113+
return new Promise((resolve, reject) => {
114+
resolve();
115+
});
116+
};
117+
/**
118+
*
119+
* @param pushId
120+
* @return {Promise<any>}
121+
*/
122+
setPushId(pushId: string): Promise<any> {
123+
return new Promise((resolve, reject) => {
124+
resolve();
125+
});
126+
};
127+
/**
128+
*
129+
* @param peopleProperties
130+
* @return {Promise<any>}
131+
*/
132+
set(peopleProperties: any): Promise<any> {
133+
return new Promise((resolve, reject) => {
134+
resolve();
135+
});
136+
};
137+
/**
138+
*
139+
* @param peopleProperties
140+
* @return {Promise<any>}
141+
*/
142+
setOnce(peopleProperties: any): Promise<any> {
143+
return new Promise((resolve, reject) => {
144+
resolve();
145+
});
146+
};
147+
}

0 commit comments

Comments
 (0)