2015-09-14 18:59:09 -04:00
|
|
|
import {
|
|
|
|
AsyncTestCompleter,
|
|
|
|
beforeEach,
|
|
|
|
ddescribe,
|
|
|
|
describe,
|
|
|
|
el,
|
|
|
|
expect,
|
|
|
|
iit,
|
|
|
|
inject,
|
|
|
|
it,
|
|
|
|
xit,
|
|
|
|
TestComponentBuilder
|
2015-10-13 03:29:13 -04:00
|
|
|
} from 'angular2/testing_internal';
|
2015-09-14 18:59:09 -04:00
|
|
|
|
2015-11-05 17:07:57 -05:00
|
|
|
import {SourceModule, moduleRef} from 'angular2/src/compiler/source_module';
|
2015-09-14 18:59:09 -04:00
|
|
|
|
|
|
|
export function main() {
|
|
|
|
describe('SourceModule', () => {
|
|
|
|
describe('getSourceWithImports', () => {
|
|
|
|
it('should generate named imports for modules', () => {
|
|
|
|
var sourceWithImports =
|
2015-10-01 13:07:49 -04:00
|
|
|
new SourceModule('package:some/moda', `${moduleRef('package:some/modb')}A`)
|
|
|
|
.getSourceWithImports();
|
2015-09-14 18:59:09 -04:00
|
|
|
expect(sourceWithImports.source).toEqual('import0.A');
|
2015-10-01 13:07:49 -04:00
|
|
|
expect(sourceWithImports.imports).toEqual([['package:some/modb', 'import0']]);
|
2015-09-14 18:59:09 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should dedupe imports', () => {
|
|
|
|
var sourceWithImports =
|
2015-10-01 13:07:49 -04:00
|
|
|
new SourceModule(
|
|
|
|
'package:some/moda',
|
|
|
|
`${moduleRef('package:some/modb')}A + ${moduleRef('package:some/modb')}B`)
|
2015-09-14 18:59:09 -04:00
|
|
|
.getSourceWithImports();
|
|
|
|
expect(sourceWithImports.source).toEqual('import0.A + import0.B');
|
2015-10-01 13:07:49 -04:00
|
|
|
expect(sourceWithImports.imports).toEqual([['package:some/modb', 'import0']]);
|
2015-09-14 18:59:09 -04:00
|
|
|
});
|
|
|
|
|
2015-10-01 13:07:49 -04:00
|
|
|
it('should not use an import for the moduleUrl of the SourceModule', () => {
|
2015-09-14 18:59:09 -04:00
|
|
|
var sourceWithImports =
|
2015-10-01 13:07:49 -04:00
|
|
|
new SourceModule('package:some/moda', `${moduleRef('package:some/moda')}A`)
|
|
|
|
.getSourceWithImports();
|
2015-09-14 18:59:09 -04:00
|
|
|
expect(sourceWithImports.source).toEqual('A');
|
|
|
|
expect(sourceWithImports.imports).toEqual([]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|