Created
December 4, 2017 17:25
-
-
Save sebastienlevert/d678b633888625a6e64fb2b147aa2419 to your computer and use it in GitHub Desktop.
This file contains 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
//...} | |
@NgModule({ | |
imports: [BrowserModule], | |
declarations: [MockData], | |
providers: [ | |
{ provide: ListsService, useFactory: ListsServiceFactory } | |
], | |
entryComponents: [MockData] | |
}) | |
export class MockDataModule { | |
ngDoBootstrap(){} | |
} | |
/** | |
* Lists Service Factory that provides the right service based on the context of the running WebPart | |
*/ | |
export function ListsServiceFactory() { | |
if (Environment.type === EnvironmentType.Local) { | |
return new MockListsService(); | |
} else if (Environment.type == EnvironmentType.SharePoint || Environment.type == EnvironmentType.ClassicSharePoint) { | |
return new ListsService(); | |
} | |
}; | |
https://gist.github.com/sebastienlevert/d678b633888625a6e64fb2b147aa2419#file-mock-data-module-ts-L19 should be replaced by if (Environment.type === EnvironmentType.Local || Environment.type === EnvironmentType.Test) {
to cover all case and support unit tests
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/sebastienlevert/d678b633888625a6e64fb2b147aa2419#file-mock-data-module-ts-L21 should be replaced by
Environment.type === EnvironmentType.SharePoint || Environment.type === EnvironmentType.ClassicSharePoint
to avoid lint errors