-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
@angular/upgrade/static
(ngUpgrade for A…
…oT apps) These kids and their new fangled "ahead of time compilation." They're upgrading their apps using `@angular/upgrade/static` now. I guess we should get with the times and run tests against a webapp running this hip new API.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,61 @@ | ||
describe('async angular1/2 hybrid using ngUpgrade application', function() { | ||
beforeEach(function() { | ||
browser.get('/hybrid'); | ||
}); | ||
describe('@angular/upgrade/static', function() { | ||
beforeEach(function() { | ||
browser.get('/upgrade'); | ||
}); | ||
|
||
it('should set browser flag via config', function() { | ||
expect(browser.ng12Hybrid).toBe(true); | ||
}); | ||
it('should set browser flag via config', function() { | ||
expect(browser.ng12Hybrid).toBe(true); | ||
}); | ||
|
||
it('should be able to click buttons and wait for $timeout', function() { | ||
var rootBtn = $$('my-app button').first(); | ||
expect(rootBtn.getText()).toEqual('Click Count: 0'); | ||
rootBtn.click(); | ||
expect(rootBtn.getText()).toEqual('Click Count: 1'); | ||
|
||
var ng2Btn = $$('ng2 button').first(); | ||
expect(ng2Btn.getText()).toEqual('Click Count: 0'); | ||
ng2Btn.click(); | ||
expect(ng2Btn.getText()).toEqual('Click Count: 1'); | ||
|
||
var ng1Btn = $('ng1 button'); | ||
expect(ng1Btn.getText()).toEqual('Click Count: 0'); | ||
ng1Btn.click(); | ||
expect(ng1Btn.getText()).toEqual('Click Count: 1'); | ||
}); | ||
|
||
it('should be able to click buttons and wait for $timeout', function() { | ||
var rootBtn = $$('my-app button').first(); | ||
expect(rootBtn.getText()).toEqual('Click Count: 0'); | ||
rootBtn.click(); | ||
expect(rootBtn.getText()).toEqual('Click Count: 1'); | ||
|
||
var ng2Btn = $$('ng2 button').first(); | ||
expect(ng2Btn.getText()).toEqual('Click Count: 0'); | ||
ng2Btn.click(); | ||
expect(ng2Btn.getText()).toEqual('Click Count: 1'); | ||
|
||
var ng1Btn = $('ng1 button'); | ||
expect(ng1Btn.getText()).toEqual('Click Count: 0'); | ||
ng1Btn.click(); | ||
expect(ng1Btn.getText()).toEqual('Click Count: 1'); | ||
it('should use the flag on the browser object', function() { | ||
browser.ng12Hybrid = false; | ||
browser.get('/ng2'); // will time out if Protractor expects hybrid | ||
browser.ng12Hybrid = true; | ||
}); | ||
}); | ||
|
||
it('should use the flag on the browser object', function() { | ||
browser.ng12Hybrid = false; | ||
browser.get('/ng2'); // will time out if Protractor expects hybrid | ||
browser.ng12Hybrid = true; | ||
describe('@angular/upgrade (not static)', function() { | ||
beforeEach(function() { | ||
browser.get('/upgrade?no_static'); | ||
}); | ||
|
||
it('should set browser flag via config', function() { | ||
expect(browser.ng12Hybrid).toBe(true); | ||
}); | ||
|
||
it('should be able to click buttons and wait for $timeout', function() { | ||
var rootBtn = $$('my-app button').first(); | ||
expect(rootBtn.getText()).toEqual('Click Count: 0'); | ||
rootBtn.click(); | ||
expect(rootBtn.getText()).toEqual('Click Count: 1'); | ||
|
||
var ng2Btn = $$('ng2 button').first(); | ||
expect(ng2Btn.getText()).toEqual('Click Count: 0'); | ||
ng2Btn.click(); | ||
expect(ng2Btn.getText()).toEqual('Click Count: 1'); | ||
|
||
var ng1Btn = $('ng1 button'); | ||
expect(ng1Btn.getText()).toEqual('Click Count: 0'); | ||
ng1Btn.click(); | ||
expect(ng1Btn.getText()).toEqual('Click Count: 1'); | ||
}); | ||
}); | ||
}); |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
import { UpgradeModule } from '@angular/upgrade/static'; | ||
|
||
import { AppModule } from './module'; | ||
|
||
platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => { | ||
const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule; | ||
upgrade.bootstrap(document.body, ['upgradeApp'], {strictDi: true}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
declare var angular: angular.IAngularStatic; | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { UpgradeModule, downgradeComponent } from '@angular/upgrade/static'; | ||
|
||
import { RootDirective } from './myApp'; | ||
import { Ng2Component } from './ng2'; | ||
import { Ng1Directive, Ng1Component } from './ng1'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
BrowserModule, | ||
UpgradeModule | ||
], | ||
declarations: [ | ||
Ng2Component, | ||
Ng1Component, | ||
], | ||
entryComponents: [ | ||
Ng2Component | ||
] | ||
}) | ||
export class AppModule { | ||
ngDoBootstrap() {} | ||
} | ||
|
||
angular.module('upgradeApp', []) | ||
.directive('ng1', Ng1Directive) | ||
.directive('ng2', downgradeComponent({ | ||
component: Ng2Component, | ||
}) as angular.IDirectiveFactory) | ||
.directive('myApp', RootDirective); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.