2016-01-06 17:13:44 -05:00
|
|
|
import {
|
|
|
|
ddescribe,
|
|
|
|
describe,
|
|
|
|
xdescribe,
|
|
|
|
it,
|
|
|
|
iit,
|
|
|
|
xit,
|
|
|
|
expect,
|
|
|
|
beforeEach,
|
|
|
|
afterEach,
|
|
|
|
AsyncTestCompleter,
|
|
|
|
inject,
|
|
|
|
beforeEachProviders,
|
|
|
|
el
|
|
|
|
} from 'angular2/testing_internal';
|
|
|
|
|
|
|
|
import {IS_DART} from 'angular2/src/facade/lang';
|
|
|
|
import {Injector} from 'angular2/core';
|
|
|
|
|
2016-04-13 20:05:17 -04:00
|
|
|
import {ComponentFactory} from 'angular2/src/core/linker/component_factory';
|
2016-01-06 17:13:44 -05:00
|
|
|
import * as typed from './offline_compiler_codegen_typed';
|
|
|
|
import * as untyped from './offline_compiler_codegen_untyped';
|
|
|
|
|
|
|
|
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
|
|
|
import {SharedStylesHost} from "angular2/src/platform/dom/shared_styles_host";
|
|
|
|
|
|
|
|
import {CompA} from './offline_compiler_util';
|
|
|
|
|
|
|
|
export function main() {
|
2016-04-13 20:05:17 -04:00
|
|
|
var typedComponentFactory = typed.CompANgFactory;
|
|
|
|
var untypedComponentFactory = untyped.CompANgFactory;
|
2016-04-30 13:52:04 -04:00
|
|
|
var fixtures: TestFixture[] = [];
|
2016-01-06 17:13:44 -05:00
|
|
|
|
|
|
|
if (IS_DART || !DOM.supportsDOMEvents()) {
|
|
|
|
// Our generator only works on node.js and Dart...
|
2016-04-30 13:52:04 -04:00
|
|
|
fixtures.push(new TestFixture(typedComponentFactory, 'typed'));
|
2016-01-06 17:13:44 -05:00
|
|
|
}
|
|
|
|
if (!IS_DART) {
|
|
|
|
// Our generator only works on node.js and Dart...
|
|
|
|
if (!DOM.supportsDOMEvents()) {
|
2016-04-30 13:52:04 -04:00
|
|
|
fixtures.push(new TestFixture(untypedComponentFactory, 'untyped'));
|
2016-01-06 17:13:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
describe('OfflineCompiler', () => {
|
|
|
|
var injector: Injector;
|
|
|
|
var sharedStylesHost: SharedStylesHost;
|
|
|
|
|
2016-04-13 20:05:17 -04:00
|
|
|
beforeEach(inject([Injector, SharedStylesHost], (_injector, _sharedStylesHost) => {
|
|
|
|
injector = _injector;
|
|
|
|
sharedStylesHost = _sharedStylesHost;
|
|
|
|
}));
|
2016-01-06 17:13:44 -05:00
|
|
|
|
2016-04-30 13:52:04 -04:00
|
|
|
fixtures.forEach((fixture) => {
|
|
|
|
describe(`${fixture.name}`, () => {
|
2016-01-06 17:13:44 -05:00
|
|
|
it('should compile components', () => {
|
2016-04-30 13:52:04 -04:00
|
|
|
var hostEl = fixture.compFactory.create(injector);
|
|
|
|
expect(hostEl.instance).toBeAnInstanceOf(CompA);
|
2016-01-06 17:13:44 -05:00
|
|
|
var styles = sharedStylesHost.getAllStyles();
|
|
|
|
expect(styles[0]).toContain('.redStyle[_ngcontent');
|
|
|
|
expect(styles[1]).toContain('.greenStyle[_ngcontent');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2016-04-30 13:52:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
class TestFixture {
|
|
|
|
constructor(public compFactory: ComponentFactory<CompA>, public name: string) {}
|
2016-01-06 17:13:44 -05:00
|
|
|
}
|