Created
December 7, 2018 14:14
-
-
Save aVolpe/9fb952e4b5d9206d6cb92ef26ce2a17c to your computer and use it in GitHub Desktop.
Simple mocks for ionic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class MockLoading { | |
public visible: boolean; | |
constructor(props: any) { | |
Object.assign(this, props); | |
this.visible = false; | |
} | |
present() { | |
this.visible = true; | |
return Promise.resolve(); | |
} | |
dismiss() { | |
this.visible = false; | |
return Promise.resolve(); | |
} | |
} | |
export class MockLoadingController { | |
public created: MockLoading[]; | |
constructor() { | |
this.created = []; | |
} | |
create(props: any): Promise<any> { | |
const toRet = new MockLoading(props); | |
this.created.push(toRet); | |
return Promise.resolve(toRet); | |
} | |
getLast() { | |
if (!this.created.length) { | |
return null; | |
} | |
return this.created[this.created.length - 1]; | |
} | |
} | |
export class MockAlert { | |
public visible: boolean; | |
public header: string; | |
public message: string; | |
constructor(props: any) { | |
Object.assign(this, props); | |
this.visible = false; | |
} | |
present() { | |
this.visible = true; | |
return Promise.resolve(); | |
} | |
dismiss() { | |
this.visible = false; | |
return Promise.resolve(); | |
} | |
} | |
export class MockAlertController { | |
public created: MockAlert[]; | |
constructor() { | |
this.created = []; | |
} | |
create(props: any): Promise<any> { | |
const toRet = new MockAlert(props); | |
this.created.push(toRet); | |
return Promise.resolve(toRet); | |
} | |
getLast() { | |
if (!this.created.length) { | |
return null; | |
} | |
return this.created[this.created.length - 1]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment