Skip to content

Instantly share code, notes, and snippets.

@gmoothart
Last active April 10, 2017 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmoothart/df8636b74a61768288ea9c0da9e13d9d to your computer and use it in GitHub Desktop.
Save gmoothart/df8636b74a61768288ea9c0da9e13d9d to your computer and use it in GitHub Desktop.
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();
}));
});
/**
* 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