Last active
April 10, 2017 16:57
-
-
Save gmoothart/df8636b74a61768288ea9c0da9e13d9d 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
describe('ng-upgrade test', () => { | |
beforeEach(async(() => { | |
angular.mock.module(appContextModule.name); | |
const ng1InjectorProvider = { | |
provide: '$injector', | |
useFactory: () => { | |
return { | |
'get': (token: string) => { | |
let dependency: {}|null = null; | |
inject([ | |
token, | |
function(t: {}) { | |
dependency = t; | |
} | |
]); | |
return dependency; | |
}, | |
}; | |
}, | |
}; | |
TestBed | |
.configureTestingModule({ | |
imports: [ComponentModule], | |
providers: [ | |
ng1InjectorProvider, | |
appContextProvider, | |
], | |
}) | |
.compileComponents(); | |
})); | |
}); |
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
/** | |
* Provider functions for using angularJS services from Angular with ng-upgrade | |
*/ | |
export function appContextFactory(i: ng.auto.IInjectorService): AppContext { | |
return i.get<AppContext>('appContext'); | |
} | |
export const appContextProvider = { | |
provide: AppContext, | |
useFactory: appContextFactory, | |
deps: ['$injector'], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment