2016-04-07 20:17:50 -04:00
|
|
|
import {ddescribe, describe, xdescribe, it, iit, xit, expect, beforeEach, afterEach, AsyncTestCompleter, inject} from 'angular2/testing_internal';
|
2015-11-06 20:34:07 -05:00
|
|
|
import {IS_DART} from 'angular2/src/facade/lang';
|
2015-08-28 14:45:39 -04:00
|
|
|
|
|
|
|
import {evalModule} from './eval_module';
|
|
|
|
|
|
|
|
// This export is used by this test code
|
|
|
|
// when evaling the test module!
|
|
|
|
export var TEST_VALUE = 23;
|
|
|
|
|
2015-11-05 17:07:57 -05:00
|
|
|
const THIS_MODULE_URL = `package:angular2/test/compiler/eval_module_spec${IS_DART?'.dart':'.js'}`;
|
2015-09-14 18:59:09 -04:00
|
|
|
|
2015-08-28 14:45:39 -04:00
|
|
|
export function main() {
|
2016-01-25 20:20:06 -05:00
|
|
|
// Dart's isolate support is broken, and these tests will be obsolote soon with
|
|
|
|
// https://github.com/angular/angular/issues/6270
|
|
|
|
if (IS_DART) {
|
|
|
|
return;
|
|
|
|
}
|
2015-08-28 14:45:39 -04:00
|
|
|
describe('evalModule', () => {
|
2015-09-02 18:07:31 -04:00
|
|
|
it('should call the "run" function and allow to use imports',
|
|
|
|
inject([AsyncTestCompleter], (async) => {
|
2015-08-28 14:45:39 -04:00
|
|
|
var moduleSource = IS_DART ? testDartModule : testJsModule;
|
2016-04-07 20:17:50 -04:00
|
|
|
evalModule(moduleSource, [[THIS_MODULE_URL, 'tst']], [1]).then((value) => {
|
|
|
|
expect(value).toEqual([1, 23]);
|
|
|
|
async.done();
|
|
|
|
});
|
2015-08-28 14:45:39 -04:00
|
|
|
}));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var testDartModule = `
|
2015-09-14 18:59:09 -04:00
|
|
|
run(data) {
|
|
|
|
data.add(tst.TEST_VALUE);
|
2015-08-28 14:45:39 -04:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
var testJsModule = `
|
|
|
|
exports.run = function(data) {
|
2015-09-14 18:59:09 -04:00
|
|
|
data.push(tst.TEST_VALUE);
|
2015-08-28 14:45:39 -04:00
|
|
|
return data;
|
|
|
|
}
|
2015-10-02 10:57:29 -04:00
|
|
|
`;
|