feat(upgrade): allow setting the angularjs lib at runtime (#15168)

Readds 8ad464d90e.
This commit is contained in:
Tobias Bosch
2017-04-14 11:25:56 -07:00
parent a77b126d72
commit e927aeae86
4 changed files with 87 additions and 16 deletions

View File

@ -12,7 +12,7 @@ import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import * as angular from '@angular/upgrade/src/common/angular1';
import {$INJECTOR, INJECTOR_KEY} from '@angular/upgrade/src/common/constants';
import {UpgradeModule, downgradeInjectable} from '@angular/upgrade/static';
import {UpgradeModule, downgradeInjectable, getAngularLib, setAngularLib} from '@angular/upgrade/static';
import {bootstrap, html} from '../test_helpers';
@ -99,5 +99,33 @@ export function main() {
expect(runBlockTriggered).toBeTruthy();
});
}));
it('should allow resetting angular at runtime', async(() => {
let wrappedBootstrapepedCalled = false;
const n: any = getAngularLib();
setAngularLib({
bootstrap: (...args: any[]) => {
wrappedBootstrapepedCalled = true;
n.bootstrap(...args);
},
module: n.module,
element: n.element,
version: n.version,
resumeBootstrap: n.resumeBootstrap,
getTestability: n.getTestability
});
@NgModule({imports: [BrowserModule, UpgradeModule]})
class Ng2Module {
ngDoBootstrap() {}
}
const ng1Module = angular.module('ng1Module', []);
bootstrap(platformBrowserDynamic(), Ng2Module, html('<div>'), ng1Module)
.then((upgrade) => { expect(wrappedBootstrapepedCalled).toEqual(true); });
}));
});
}